@dual-os/sdk 0.12.3 → 0.13.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/README.md +1 -0
- package/dist/AgentChannel.js +2 -2
- package/dist/AgentChannelRuntime.d.ts +0 -2
- package/dist/AgentChannelRuntime.d.ts.map +1 -1
- package/dist/AgentChannelRuntime.js +5 -8
- package/dist/AgentChannelRuntime.js.map +1 -1
- package/dist/AiProvider.d.ts +1 -1
- package/dist/AiProvider.js +2 -2
- package/dist/AuthMethod.js +1 -1
- package/dist/AuthMethodExecution.js +2 -2
- package/dist/ConnectionResolver.d.ts +0 -1
- package/dist/ConnectionResolver.d.ts.map +1 -1
- package/dist/ConnectionResolver.js.map +1 -1
- package/dist/DualRegistry.d.ts +6 -6
- package/dist/DualRegistry.d.ts.map +1 -1
- package/dist/DualRegistry.js +1 -1
- package/dist/DualRuntime.d.ts +26 -26
- package/dist/DualRuntime.d.ts.map +1 -1
- package/dist/DualRuntime.js +6 -6
- package/dist/DualRuntime.js.map +1 -1
- package/dist/Group.d.ts +1 -1
- package/dist/Group.js +2 -2
- package/dist/Http.d.ts +1 -1
- package/dist/OAuthFlow.js +1 -1
- package/dist/Plugin.d.ts +46 -46
- package/dist/Plugin.js +3 -3
- package/dist/PluginRuntime.d.ts +0 -9
- package/dist/PluginRuntime.d.ts.map +1 -1
- package/dist/Runner.js +1 -1
- package/dist/Trigger.d.ts +3 -3
- package/dist/index.d.ts +14 -14
- package/dist/index.js +12 -12
- package/dist/internal/auth-context.d.ts +1 -1
- package/dist/internal/auth-execution.d.ts +1 -1
- package/dist/internal/auth-execution.d.ts.map +1 -1
- package/dist/internal/auth-execution.js.map +1 -1
- package/dist/internal/capabilities.d.ts +4 -4
- package/dist/internal/children.d.ts +5 -5
- package/dist/internal/children.js +2 -2
- package/dist/internal/dual/actions.d.ts +8 -8
- package/dist/internal/dual/actions.d.ts.map +1 -1
- package/dist/internal/dual/invoke.d.ts +6 -6
- package/dist/internal/dual/invoke.d.ts.map +1 -1
- package/dist/internal/dual/invoke.js +1 -1
- package/dist/internal/dual/invoke.js.map +1 -1
- package/dist/internal/dual/registry.d.ts +2 -2
- package/dist/internal/dual/triggers.d.ts +11 -11
- package/dist/internal/plugin-handlers.d.ts +11 -11
- package/dist/internal/plugin-handlers.d.ts.map +1 -1
- package/dist/internal/plugin-handlers.js +3 -3
- package/dist/internal/plugin-handlers.js.map +1 -1
- package/dist/internal/trigger-runtime-shared.d.ts +1 -1
- package/dist/internal/trigger-runtime-shared.d.ts.map +1 -1
- package/dist/internal/trigger-runtime-shared.js +2 -2
- package/dist/internal/trigger-runtime-shared.js.map +1 -1
- package/dist/internal/trigger-runtime.d.ts +1 -1
- package/dist/remote-runtime.d.ts +0 -2
- package/dist/remote-runtime.d.ts.map +1 -1
- package/dist/remote-runtime.js +12 -15
- package/dist/remote-runtime.js.map +1 -1
- package/package.json +2 -3
- package/src/AgentChannelRuntime.ts +3 -6
- package/src/ConnectionResolver.ts +0 -1
- package/src/DualRuntime.ts +13 -15
- package/src/internal/auth-execution.ts +12 -14
- package/src/internal/dual/invoke.ts +11 -14
- package/src/internal/plugin-handlers.ts +12 -13
- package/src/internal/trigger-runtime-shared.ts +3 -4
- package/src/remote-runtime.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DualRuntime.d.ts","names":["Plugin.Any","AiProvider.Any","Plugin.LayerOutput","Plugin.LayerError","Plugin.LayerRequirements","Trigger.WebhookRequest","AuthMethod.OAuth2TokenResponse","AuthMethod.RefreshReason","AiProvider.RuntimeModel","AuthMethod.ExpectedOAuth2MethodError","AuthMethod.OAuth2RefreshTokenUnavailableError","AuthMethod.AuthMethodHookError","AuthMethodExecution.JsonRequest","AgentChannelRuntime.Interface","Trigger.ActivateSuccess","Trigger.DeactivateSuccess","Trigger.VerifySuccess","Trigger.EmittedEventsSuccess","AuthMethod.Any","AuthMethodBinding.Binding","AiProvider.AllowedModelIds","AiProvider.RuntimeConfig","AgentChannelRuntime.Requirements","AuthMethod.SetupSchema","AuthMethod.InputSchema","AuthMethod.Requirements","AuthMethod.MaterialSchema","AuthMethod.ValueSchema"],"sources":["../src/DualRuntime.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;iBAqEiB,mBAAmB,UAAUA,QAAaA;WAChD,QAAQ;;WAER;;;;;;;;iBASM,QACX,UAAUA,QAAaA,OAC3B,yBACI,wBACA,+BACA,6BAA6BC,
|
|
1
|
+
{"version":3,"file":"DualRuntime.d.ts","names":["Plugin.Any","AiProvider.Any","Plugin.LayerOutput","Plugin.LayerError","Plugin.LayerRequirements","Trigger.WebhookRequest","AuthMethod.OAuth2TokenResponse","AuthMethod.RefreshReason","AiProvider.RuntimeModel","AuthMethod.ExpectedOAuth2MethodError","AuthMethod.OAuth2RefreshTokenUnavailableError","AuthMethod.AuthMethodHookError","AuthMethodExecution.JsonRequest","AgentChannelRuntime.Interface","Trigger.ActivateSuccess","Trigger.DeactivateSuccess","Trigger.VerifySuccess","Trigger.EmittedEventsSuccess","AuthMethod.Any","AuthMethodBinding.Binding","AiProvider.AllowedModelIds","AiProvider.RuntimeConfig","AgentChannelRuntime.Requirements","AuthMethod.SetupSchema","AuthMethod.InputSchema","AuthMethod.Requirements","AuthMethod.MaterialSchema","AuthMethod.ValueSchema"],"sources":["../src/DualRuntime.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;iBAqEiB,mBAAmB,UAAUA,QAAaA;WAChD,QAAQ;;WAER;;;;;;;;iBASM,QACX,UAAUA,QAAaA,OAC3B,yBACI,wBACA,+BACA,6BAA6BC,iBAA4BA;WAEpD;WACA,aAAa;WACb,kBAAkB,mBAAmB;WACrC,OAAO,MAAM,MAAM,aAAa,YAAY;;;;;;;;iBAStC,eAAe,IAAID,iCAAsCC;;;;;;;qBAQ7D,UAAW,UAAUD,OAAU,QAClC,GAAC,oBAER,mBAAmB;;;;;;;;qBAST,mBAAoB,UAAUA,OAAU,QAC3C,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,UAAUD,OAChB,aACA,YACA,yBACM,6BAA6BC,OAAgB,KAE9C,IAAI,GAAG,aAAa,YAAY,mBAAmB,iBACvD,MAAM,MACP,SACA,YACE,oBACA,QAAQ,uBAAuB,IAAI,eACnC,QAAQ,mCAAmC,IAAI,sBAAsB"}
|
package/dist/DualRuntime.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { BuilderCollisionError } from "./DefinitionError.js";
|
|
3
2
|
import { ActionHandlerError, RetryableActionHandlerError } from "./Action.js";
|
|
3
|
+
import { Service as Service$1, layer } from "./AgentChannelRuntime.js";
|
|
4
|
+
import { RuntimeConfig, registryId } from "./AiProvider.js";
|
|
4
5
|
import { makeBinding } from "./AuthMethodBinding.js";
|
|
5
6
|
import { decodeSetup, executeJson, prepare, prepareOAuth2Tokens, refreshUnknown, resolve, resolveDecoded } from "./AuthMethodExecution.js";
|
|
6
7
|
import { ConnectionIdNotAllowedError, ConnectionReauthorizationRequiredError, ConnectionRequiredError, ConnectionResolverStoreError, ConnectionSelectionRequiredError, InvalidConnectionIdError, InvalidResolvedConnectionError } from "./ConnectionResolver.js";
|
|
7
|
-
import {
|
|
8
|
-
import { Service as Service$1, layer } from "./AgentChannelRuntime.js";
|
|
9
|
-
import { RuntimeConfig, registryId } from "./AiProvider.js";
|
|
10
|
-
import { resolveAction } from "./internal/dual/actions.js";
|
|
11
|
-
import { resolveRuntimeTrigger } from "./internal/dual/triggers.js";
|
|
8
|
+
import { BuilderCollisionError } from "./DefinitionError.js";
|
|
12
9
|
import { TriggerNotFoundError } from "./DualRegistry.js";
|
|
13
10
|
import { authRuntimeContext } from "./internal/auth-execution.js";
|
|
11
|
+
import { resolveAction } from "./internal/dual/actions.js";
|
|
14
12
|
import { ActionHandlerNotFoundError, ActionNotFoundError, FieldIssue, InvalidActionInputError, InvalidActionOutputError, invokeResolvedAction, invokeResolvedActionJson } from "./internal/dual/invoke.js";
|
|
13
|
+
import { resolveRuntimeTrigger } from "./internal/dual/triggers.js";
|
|
14
|
+
import { indexGroups } from "./internal/handler-context.js";
|
|
15
15
|
import { activate, deactivate, parse, poll, verify } from "./Trigger.js";
|
|
16
16
|
import "./DualRuntime.js";
|
|
17
17
|
import { Array, Context, Effect, Function, Layer, Predicate, Result, Schema, pipe } from "effect";
|
package/dist/DualRuntime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DualRuntime.js","names":["Func","AiProvider.registryId","AgentChannelRuntime.Service","Trigger.activate","Trigger.deactivate","Trigger.verify","Trigger.parse","Trigger.poll","AuthMethodExecution.decodeSetup","AuthMethodExecution.prepare","prepareOAuth2Tokens","AuthMethodExecution.prepareOAuth2Tokens","AuthMethodExecution.refreshUnknown","AuthMethodExecution.resolveDecoded","AuthMethodExecution.resolve","AuthMethodBinding.makeBinding","AiProvider.RuntimeConfig","AuthMethodExecution.executeJson","AgentChannelRuntime.layer"],"sources":["../src/DualRuntime.ts"],"sourcesContent":["/**\n * Dual action invocation, trigger lifecycle, and auth runtime.\n *\n * @since 0.0.0\n */\nimport {\n Array,\n Context,\n Effect,\n Function as Func,\n Layer,\n Predicate,\n Result,\n Schema,\n pipe,\n} from \"effect\";\n\nimport { type HttpClientRequest, Url } from \"effect/http\";\n\nimport {\n ActionHandlerError,\n RetryableActionHandlerError,\n type ActionHandlerFailure,\n} from \"./Action.ts\";\nimport * as AgentChannelRuntime from \"./AgentChannelRuntime.ts\";\nimport * as AiProvider from \"./AiProvider.ts\";\nimport type * as AuthMethod from \"./AuthMethod.ts\";\nimport * as AuthMethodBinding from \"./AuthMethodBinding.ts\";\nimport * as AuthMethodExecution from \"./AuthMethodExecution.ts\";\nimport {\n ConnectionIdNotAllowedError,\n ConnectionReauthorizationRequiredError,\n ConnectionRequiredError,\n ConnectionSelectionRequiredError,\n ConnectionResolverStoreError,\n InvalidConnectionIdError,\n InvalidResolvedConnectionError,\n type ConnectionResolutionContext,\n} from \"./ConnectionResolver.ts\";\nimport { BuilderCollisionError } from \"./DefinitionError.ts\";\nimport { TriggerNotFoundError } from \"./DualRegistry.ts\";\nimport { authRuntimeContext } from \"./internal/auth-execution.ts\";\nimport { resolveAction, type PluginActions } from \"./internal/dual/actions.ts\";\nimport {\n ActionNotFoundError,\n FieldIssue,\n InvalidActionInputError,\n InvalidActionOutputError,\n ActionHandlerNotFoundError,\n type InvokeError,\n type InvokeMeta,\n type InvokeRequest,\n type InvokeRequirementsFor,\n type InvokeSuccess,\n type PluginRequirements,\n invokeResolvedAction,\n invokeResolvedActionJson,\n} from \"./internal/dual/invoke.ts\";\nimport { resolveRuntimeTrigger } from \"./internal/dual/triggers.ts\";\nimport { indexGroups } from \"./internal/handler-context.ts\";\nimport type * as Plugin from \"./Plugin.ts\";\nimport * as Trigger from \"./Trigger.ts\";\n\n/**\n * One installed plugin release.\n *\n * @since 0.7.0\n * @category models\n */\nexport interface PluginInstallation<P extends Plugin.Any = Plugin.Any> {\n readonly plugin: P;\n /** The plugin's package version. */\n readonly version: string;\n}\n\n/**\n * The plugin releases and AI providers one runtime executes, with the services their handlers need.\n *\n * @since 0.7.0\n * @category models\n */\nexport interface App<\n out P extends Plugin.Any = Plugin.Any,\n LayerOutput = never,\n out LayerError = never,\n out LayerRequirements = never,\n out AiProviders extends readonly AiProvider.Any[] = readonly AiProvider.Any[],\n> {\n readonly identifier: string;\n readonly aiProviders: AiProviders;\n readonly plugins: readonly PluginInstallation<P>[];\n readonly layer: Layer.Layer<LayerOutput, LayerError, LayerRequirements>;\n}\n\n/**\n * Constraint type for working with any {@link App}.\n *\n * @since 0.7.0\n * @category type-level\n */\nexport interface AnyApp extends App<Plugin.Any, never, any, any, readonly AiProvider.Any[]> {}\n\n/**\n * Install one plugin release.\n *\n * @since 0.7.0\n * @category constructors\n */\nexport const install = <P extends Plugin.Any>(\n plugin: P,\n version: string,\n): PluginInstallation<P> => ({ plugin, version });\n\n/**\n * The runtime of one plugin release, as the plugin's own process runs it. `version` defaults to\n * `0.0.0` for tests that do not need the package version.\n *\n * @since 0.7.0\n * @category constructors\n */\nexport const fromPlugin = <const P extends Plugin.Any>(\n plugin: P,\n version = \"0.0.0\",\n): App<\n P,\n Plugin.LayerOutput<readonly [P]>,\n Plugin.LayerError<readonly [P]>,\n Plugin.LayerRequirements<readonly [P]>,\n readonly []\n> =>\n ({\n aiProviders: [],\n identifier: plugin.identifier,\n layer: plugin.layer,\n plugins: [install(plugin, version)],\n }) as never;\n\n/**\n * An app runtime without plugins, for {@link withPlugin} and {@link withPlugins} to fill.\n *\n * @since 0.7.0\n * @category constructors\n */\nexport const make = (identifier: string): App<never, never, never, never, readonly []> => ({\n aiProviders: [],\n identifier,\n layer: Layer.empty,\n plugins: [],\n});\n\ntype AppPlugin<A extends AnyApp> = A extends App<infer P, any, any, any, any> ? P : never;\ntype AppLayerOutput<A extends AnyApp> =\n A extends App<any, infer Output, any, any, any> ? Output : never;\ntype AppLayerError<A extends AnyApp> =\n A extends App<any, any, infer Error, any, any> ? Error : never;\ntype AppLayerRequirements<A extends AnyApp> =\n A extends App<any, any, any, infer Requirements, any> ? Requirements : never;\n\n/**\n * Result of adding a plugin release to an app runtime. A named interface keeps declaration emit\n * from expanding every plugin and layer member at large call sites.\n *\n * @since 0.7.0\n * @category type-level\n */\nexport interface WithPlugin<Self extends AnyApp, Added extends Plugin.Any> extends App<\n AppPlugin<Self> | Added,\n AppLayerOutput<Self> | Plugin.LayerOutput<readonly [Added]>,\n AppLayerError<Self> | Plugin.LayerError<readonly [Added]>,\n | Plugin.LayerRequirements<readonly [Added]>\n | Exclude<AppLayerRequirements<Self>, Plugin.LayerOutput<readonly [Added]>>,\n Self[\"aiProviders\"]\n // oxlint-disable-next-line typescript/no-empty-object-type -- TypeScript declaration emit expands a type alias at every app call site (TS7056).\n> {}\n\n// Match the runtime's left-to-right provideMerge fold: later plugins can\n// satisfy earlier requirements, but earlier outputs cannot satisfy later ones.\ntype BulkLayerRequirements<\n Added extends readonly Plugin.Any[],\n Requirements,\n> = number extends Added[\"length\"]\n ? Requirements | Layer.Services<Added[number][\"layer\"]>\n : Added extends readonly [\n infer Head extends Plugin.Any,\n ...infer Tail extends readonly Plugin.Any[],\n ]\n ? BulkLayerRequirements<\n Tail,\n Layer.Services<Head[\"layer\"]> | Exclude<Requirements, Layer.Success<Head[\"layer\"]>>\n >\n : Requirements;\n\n/**\n * Result of adding several plugin releases to an app runtime in one step.\n *\n * @since 0.7.0\n * @category type-level\n */\nexport interface WithPlugins<Self extends AnyApp, Added extends readonly Plugin.Any[]> extends App<\n AppPlugin<Self> | Added[number],\n AppLayerOutput<Self> | Layer.Success<Added[number][\"layer\"]>,\n AppLayerError<Self> | Layer.Error<Added[number][\"layer\"]>,\n BulkLayerRequirements<Added, AppLayerRequirements<Self>>,\n Self[\"aiProviders\"]\n // oxlint-disable-next-line typescript/no-empty-object-type -- TypeScript declaration emit expands a type alias at every app call site (TS7056).\n> {}\n\n/** A plugin and the package version of its release. */\ntype PluginEntry = readonly [plugin: Plugin.Any, version: string];\n\ntype PluginsOf<Entries extends readonly PluginEntry[]> = {\n readonly [K in keyof Entries]: Entries[K][0];\n};\n\nfunction addPlugins(app: AnyApp, entries: readonly PluginEntry[]): AnyApp {\n const seen = new Set(Array.map(app.plugins, installation => installation.plugin.identifier));\n for (const [plugin] of entries) {\n if (seen.has(plugin.identifier)) {\n throw new BuilderCollisionError({\n childKind: \"plugin\",\n existingChildKind: \"plugin\",\n identifier: plugin.identifier,\n ownerIdentifier: app.identifier,\n ownerKind: \"dual\",\n });\n }\n seen.add(plugin.identifier);\n }\n return {\n ...app,\n layer: Array.reduce(entries, app.layer, (layer, [plugin]) =>\n Layer.provideMerge(layer, plugin.layer),\n ),\n plugins: [\n ...app.plugins,\n ...Array.map(entries, ([plugin, version]) => install(plugin, version)),\n ],\n };\n}\n\n/**\n * Add one plugin release: the plugin and its package version.\n *\n * @since 0.7.0\n * @category combinators\n */\nexport const withPlugin: {\n <const P extends Plugin.Any>(\n plugin: P,\n version: string,\n ): <Self extends AnyApp>(app: Self) => WithPlugin<Self, P>;\n <Self extends AnyApp, const P extends Plugin.Any>(\n app: Self,\n plugin: P,\n version: string,\n ): WithPlugin<Self, P>;\n} = Func.dual(3, (app: AnyApp, plugin: Plugin.Any, version: string) =>\n addPlugins(app, [[plugin, version]]),\n);\n\n/**\n * Add several plugin releases in one step, which keeps a large app's inferred type compact.\n *\n * @since 0.7.0\n * @category combinators\n */\nexport const withPlugins: {\n <const E extends readonly PluginEntry[]>(\n entries: E,\n ): <Self extends AnyApp>(app: Self) => WithPlugins<Self, PluginsOf<E>>;\n <Self extends AnyApp, const E extends readonly PluginEntry[]>(\n app: Self,\n entries: E,\n ): WithPlugins<Self, PluginsOf<E>>;\n} = Func.dual(2, addPlugins);\n\nconst pluginOf = (app: AnyApp, identifier: string): Plugin.Any | undefined =>\n app.plugins.find(installation => installation.plugin.identifier === identifier)?.plugin;\n\n/**\n * Request payload accepted by {@link invoke}.\n *\n * @since 0.0.0\n * @category models\n */\nexport type { InvokeRequest };\n\n/**\n * Metadata returned alongside successful invocation data.\n *\n * @since 0.0.0\n * @category models\n */\nexport type { InvokeMeta };\n\n/**\n * Successful invocation envelope returned by {@link invoke}.\n *\n * @since 0.0.0\n * @category models\n */\nexport type { InvokeSuccess };\n\n/**\n * Structured field-level validation issue surfaced by {@link InvalidActionInputError}.\n *\n * @since 0.0.0\n * @category models\n */\nexport { FieldIssue };\n\n/**\n * Raised when an invocation references an unknown action id.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ActionNotFoundError };\n\n/**\n * @since 0.0.0\n * @category errors\n */\n\n/**\n * Raised when invocation input fails schema validation.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { InvalidActionInputError };\n\n/**\n * Raised when action handler output fails schema validation.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { InvalidActionOutputError };\n\n/**\n * Raised when the runtime action handler service is missing.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ActionHandlerNotFoundError };\n\n/**\n * Non-retryable failure reported by a trusted action handler.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ActionHandlerError };\n\n/**\n * Retryable failure reported by a trusted action handler.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { RetryableActionHandlerError };\n\n/**\n * Stable trusted action handler failure contract.\n *\n * @since 0.0.0\n * @category errors\n */\nexport type { ActionHandlerFailure };\n\n/**\n * Raised when an action does not accept a connection but a connectionId was still provided.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ConnectionIdNotAllowedError };\n\n/**\n * Raised when invocation requires a connection and no compatible binding is available.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ConnectionRequiredError };\n\n/**\n * Raised when several compatible connection bindings exist and the caller must choose one.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ConnectionSelectionRequiredError };\n\n/**\n * Raised when the provider refuses a connection's stored grant and the user must sign in again.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ConnectionReauthorizationRequiredError };\n\n/**\n * Raised when the host connection store is unavailable.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ConnectionResolverStoreError };\n\n/**\n * Raised when a connectionId does not resolve to a compatible binding.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { InvalidConnectionIdError };\n\n/**\n * Raised when a resolved connection binding does not satisfy its auth method schema.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { InvalidResolvedConnectionError };\n\n/**\n * Structured SDK-owned invocation failures.\n *\n * @since 0.0.0\n * @category errors\n */\nexport type { InvokeError };\nexport type { InvokeRequirementsFor };\n\n/**\n * Invoke an action directly in-process.\n *\n * The invocation boundary resolves an action by canonical machine id, validates\n * unknown input against the resolved runtime schema, runs the handler, and\n * returns a standard success envelope. This mirrors the server trusted invoke\n * boundary: runtime schema validation is authoritative.\n *\n * @since 0.0.0\n * @category execution\n */\nconst failInvokeActionNotFound = (\n actionId: string,\n): Effect.Effect<InvokeSuccess, ActionNotFoundError> =>\n Effect.fail(new ActionNotFoundError({ actionId }));\n\nconst invokeRaw = <\n const P extends Plugin.Any,\n LayerOutput,\n LayerError,\n LayerRequirements,\n const AiProviders extends readonly AiProvider.Any[],\n>(\n app: App<P, LayerOutput, LayerError, LayerRequirements, AiProviders>,\n request: InvokeRequest,\n json = false,\n): Effect.Effect<InvokeSuccess, InvokeError, RuntimeRequirementsFor<P>> => {\n const resolved = resolveAction(app.plugins, request.actionId, request.actionVersion);\n\n if (\n resolved === undefined ||\n (request.pluginKey !== undefined && resolved.providerId !== request.pluginKey)\n ) {\n return failInvokeActionNotFound(request.actionId);\n }\n\n // The runtime entry is resolved from erased plugin trees, so the precise\n // per-action requirement union in the return annotation cannot be recovered\n // here; the annotation is the contract, the cast is the boundary.\n return (json ? invokeResolvedActionJson : invokeResolvedAction)(\n resolved.providerId,\n resolved.actionId,\n resolved.pluginVersion,\n resolved.action,\n resolved.authMethods,\n request,\n ) as never;\n};\n\nexport const invoke = <\n const P extends Plugin.Any,\n LayerOutput,\n LayerError,\n LayerRequirements,\n const AiProviders extends readonly AiProvider.Any[],\n>(\n app: App<P, LayerOutput, LayerError, LayerRequirements, AiProviders>,\n request: InvokeRequest,\n): Effect.Effect<\n InvokeSuccess,\n InvokeError | LayerError,\n LayerRequirements | Exclude<RuntimeRequirementsFor<P>, LayerOutput>\n> => invokeRaw(app, request).pipe(Effect.provide(app.layer));\n\n/**\n * Runtime-first invocation request accepted by {@link Service}.\n *\n * @since 0.0.0\n * @category models\n */\nexport type RuntimeInvokeRequest = InvokeRequest;\n\n/**\n * Runtime-first trigger lifecycle request accepted by {@link Service}.\n *\n * @since 0.0.0\n * @category models\n */\nexport interface RuntimeTriggerLifecycleRequest {\n readonly triggerId: string;\n readonly pluginKey?: string;\n /** The exact plugin release the caller pinned; another installed release does not run. */\n readonly triggerVersion?: string | undefined;\n readonly config: unknown;\n readonly state?: unknown | undefined;\n readonly connectionId?: string | undefined;\n readonly context?: ConnectionResolutionContext | undefined;\n}\n\nexport interface RuntimeWebhookActivationRequest extends RuntimeTriggerLifecycleRequest {\n readonly webhookUrl: string;\n}\n\nexport interface RuntimeWebhookTriggerLifecycleRequest extends RuntimeWebhookActivationRequest {\n readonly request: Trigger.WebhookRequest;\n}\n\nexport interface AuthMethodRequest {\n readonly providerId: string;\n readonly authMethodId: string;\n}\n\nexport interface DecodeAuthMethodSetupRequest extends AuthMethodRequest {\n readonly encoding?: \"json\";\n readonly setup: unknown;\n}\n\nexport interface PrepareAuthMethodRequest extends AuthMethodRequest {\n readonly input: unknown;\n readonly setup: unknown;\n}\n\nexport interface PrepareOAuth2TokensRequest extends AuthMethodRequest {\n readonly tokens: AuthMethod.OAuth2TokenResponse;\n readonly setup: unknown;\n}\n\nexport interface RefreshAuthMethodRequest extends AuthMethodRequest {\n readonly material: unknown;\n readonly setup: unknown;\n readonly now: number;\n readonly minValidityMs: number;\n readonly reason: AuthMethod.RefreshReason;\n}\n\nexport interface ResolveAuthMethodRequest extends AuthMethodRequest {\n /** `json` when the material and setup arrive in their canonical JSON encoding, as in the sandbox. */\n readonly encoding?: \"json\";\n readonly material: unknown;\n readonly setup: unknown;\n}\n\nexport interface ResolveAiModelConfigRequest extends ResolveAuthMethodRequest {\n readonly model: AiProvider.RuntimeModel;\n}\n\nexport class AuthMethodNotFoundError extends Schema.TaggedError<AuthMethodNotFoundError>()(\n \"AuthMethodNotFoundError\",\n { authMethodId: Schema.String, providerId: Schema.String },\n) {}\n\nexport type AuthMethodExecutionError =\n | AuthMethodNotFoundError\n | Schema.SchemaError\n | AuthMethod.ExpectedOAuth2MethodError\n | AuthMethod.OAuth2RefreshTokenUnavailableError\n | AuthMethod.AuthMethodHookError;\n\nexport class AiProviderRuntimeNotConfiguredError extends Schema.TaggedError<AiProviderRuntimeNotConfiguredError>()(\n \"AiProviderRuntimeNotConfiguredError\",\n { providerId: Schema.String },\n) {}\n\nexport class AiModelNotAllowedError extends Schema.TaggedError<AiModelNotAllowedError>()(\n \"AiModelNotAllowedError\",\n { modelId: Schema.String, providerId: Schema.String },\n) {}\n\nexport type AiModelConfigError =\n | AuthMethodExecutionError\n | AiProviderRuntimeNotConfiguredError\n | AiModelNotAllowedError;\n\n/** Raised when a provider declares no sandbox access. */\nexport class SandboxAccessNotDeclaredError extends Schema.TaggedError<SandboxAccessNotDeclaredError>()(\n \"SandboxAccessNotDeclaredError\",\n { providerId: Schema.String },\n) {}\n\n/** Raised when the Connection may not be sent with a sandbox request: another origin, or a request the provider refuses. */\nexport class SandboxRequestNotAllowedError extends Schema.TaggedError<SandboxRequestNotAllowedError>()(\n \"SandboxRequestNotAllowedError\",\n { origin: Schema.String, path: Schema.String, providerId: Schema.String },\n) {}\n\nexport type SandboxAccessError = AuthMethodExecutionError | SandboxAccessNotDeclaredError;\n\n/** One Connection's sandbox access: where its credential may go, and how a request gets it. */\nexport interface ResolvedSandboxAccess {\n readonly origins: readonly string[];\n readonly authorize: (\n request: HttpClientRequest.HttpClientRequest,\n ) => Effect.Effect<HttpClientRequest.HttpClientRequest, SandboxRequestNotAllowedError>;\n}\n\n/**\n * Runtime service materialized from an {@link App}.\n *\n * @since 0.0.0\n * @category services\n */\nexport interface RuntimeService {\n readonly executeAuthJson: (\n request: AuthMethodExecution.JsonRequest,\n ) => Effect.Effect<unknown, AuthMethodExecutionError>;\n readonly invokeJson: (\n request: RuntimeInvokeRequest,\n ) => Effect.Effect<InvokeSuccess<string, Schema.Json>, InvokeError | Schema.SchemaError>;\n readonly decodeAgentChannelDefinitionSettings: AgentChannelRuntime.Interface[\"decodeDefinitionSettings\"];\n readonly decodeAgentChannelDeploymentSettings: AgentChannelRuntime.Interface[\"decodeDeploymentSettings\"];\n readonly getAgentChannel: AgentChannelRuntime.Interface[\"get\"];\n readonly checkAccessAgentChannel: AgentChannelRuntime.Interface[\"checkAccess\"];\n readonly executeAgentChannel: AgentChannelRuntime.Interface[\"execute\"];\n readonly invoke: (request: RuntimeInvokeRequest) => Effect.Effect<InvokeSuccess, InvokeError>;\n readonly activateTrigger: (\n request: RuntimeWebhookActivationRequest,\n ) => Effect.Effect<Trigger.ActivateSuccess, unknown>;\n readonly deactivateTrigger: (\n request: RuntimeWebhookActivationRequest,\n ) => Effect.Effect<Trigger.DeactivateSuccess, unknown>;\n readonly verifyTrigger: (\n request: RuntimeWebhookTriggerLifecycleRequest,\n ) => Effect.Effect<Trigger.VerifySuccess, unknown>;\n readonly parseTrigger: (\n request: RuntimeWebhookTriggerLifecycleRequest,\n ) => Effect.Effect<Trigger.EmittedEventsSuccess<string, \"parse\">, unknown>;\n readonly pollTrigger: (\n request: RuntimeTriggerLifecycleRequest,\n ) => Effect.Effect<Trigger.EmittedEventsSuccess<string, \"poll\">, unknown>;\n readonly getAuthMethod: (\n request: AuthMethodRequest,\n ) => Effect.Effect<AuthMethod.Any, AuthMethodNotFoundError>;\n // TODO(live-schema-validation): expose live action/trigger schema decoders by capability version.\n // Server authoring/runtime must validate against SDK declarations, not JSON Schema projections.\n readonly decodeAuthMethodSetup: (\n request: DecodeAuthMethodSetupRequest,\n ) => Effect.Effect<unknown, AuthMethodExecutionError>;\n readonly prepareAuthMethod: (\n request: PrepareAuthMethodRequest,\n ) => Effect.Effect<unknown, AuthMethodExecutionError>;\n readonly prepareOAuth2Tokens: (\n request: PrepareOAuth2TokensRequest,\n ) => Effect.Effect<unknown, AuthMethodExecutionError>;\n readonly refreshAuthMethod: (\n request: RefreshAuthMethodRequest,\n ) => Effect.Effect<unknown | undefined, AuthMethodExecutionError>;\n readonly resolveAuthMethod: (\n request: ResolveAuthMethodRequest,\n ) => Effect.Effect<AuthMethodBinding.Binding, AuthMethodExecutionError>;\n readonly allowedModelIdsFor: (providerId: string) => AiProvider.AllowedModelIds | undefined;\n readonly resolveAiModelConfig: (\n request: ResolveAiModelConfigRequest,\n ) => Effect.Effect<AiProvider.RuntimeConfig, AiModelConfigError>;\n readonly resolveSandboxAccess: (\n request: ResolveAuthMethodRequest,\n ) => Effect.Effect<ResolvedSandboxAccess, SandboxAccessError>;\n}\n\n/**\n * Effect service provided by {@link toLayer}.\n *\n * @since 0.0.0\n * @category services\n */\nexport class Service extends Context.Service<Service, RuntimeService>()(\n \"@dual-os/sdk/Dual/Service\",\n) {}\n\nexport type RuntimeRequirementsFor<P extends Plugin.Any> =\n | AgentChannelRuntime.Requirements<P>\n | (P extends Plugin.Any ? PluginRequirements<P, PluginActions<P>> : never);\n\ntype AuthProvider = Plugin.Any | AiProvider.Any;\n\ntype AuthMethodFor<Providers extends AuthProvider> = Providers[\"authMethods\"][number];\n\ntype AuthMethodSetupDecodeRequirements<Method extends AuthMethod.Any> =\n AuthMethod.SetupSchema<Method> extends Schema.Top\n ? Schema.Codec.DecodingServices<AuthMethod.SetupSchema<Method>>\n : never;\n\ntype AuthMethodInputDecodeRequirements<Method extends AuthMethod.Any> =\n AuthMethod.InputSchema<Method> extends Schema.Top\n ? Schema.Codec.DecodingServices<AuthMethod.InputSchema<Method>>\n : never;\n\ntype AuthMethodExecutionRequirementsFor<Providers extends AuthProvider> =\n AuthMethodFor<Providers> extends infer Method\n ? Method extends AuthMethod.Any\n ?\n | AuthMethod.Requirements<Method>\n | AuthMethodSetupDecodeRequirements<Method>\n | AuthMethodInputDecodeRequirements<Method>\n | Schema.Codec.DecodingServices<AuthMethod.MaterialSchema<Method>>\n | Schema.Codec.DecodingServices<AuthMethod.ValueSchema<Method>>\n | Schema.Codec.EncodingServices<AuthMethod.MaterialSchema<Method>>\n | Schema.Codec.EncodingServices<AuthMethod.ValueSchema<Method>>\n | (AuthMethod.SetupSchema<Method> extends Schema.Top\n ? Schema.Codec.EncodingServices<AuthMethod.SetupSchema<Method>>\n : never)\n : never\n : never;\n\n/**\n * Requirements still needed by {@link toLayer} for an app.\n *\n * Hosts (the server, a worker, a test harness) never know an app's concrete\n * implementations: they talk to it exclusively through the generic\n * {@link Service} layer. App-specific dependencies — a plugin's API client, an\n * auth hook's token service — are discharged where they are known, at the\n * plugin or app definition (the `Exclude<..., LayerOutput>` below cancels\n * them). Only what the definition did not discharge surfaces here,\n * generically, and the host entrypoint forces it to `never` before anything\n * runs.\n *\n * @since 0.0.0\n * @category type-level\n */\nexport type ToLayerRequirements<A extends AnyApp> =\n A extends App<\n infer P extends Plugin.Any,\n infer LayerOutput,\n any,\n infer LayerRequirements,\n infer AiProviders extends readonly AiProvider.Any[]\n >\n ?\n | LayerRequirements\n | Exclude<RuntimeRequirementsFor<P>, LayerOutput>\n | Exclude<AuthMethodExecutionRequirementsFor<P | AiProviders[number]>, LayerOutput>\n : never;\n\n/**\n * Layer-construction errors surfaced by {@link toLayer} for an app.\n *\n * @since 0.0.0\n * @category type-level\n */\nexport type ToLayerError<A extends AnyApp> =\n A extends App<any, any, infer LayerError, any, any> ? LayerError : never;\n\n/**\n * Turn an {@link App} into a runtime Effect service layer.\n *\n * @since 0.0.0\n * @category layers\n */\nexport const toLayer = <\n const P extends Plugin.Any,\n LayerOutput,\n LayerError,\n LayerRequirements,\n const AiProviders extends readonly AiProvider.Any[],\n>(\n app: App<P, LayerOutput, LayerError, LayerRequirements, AiProviders>,\n): Layer.Layer<\n Service,\n LayerError,\n | LayerRequirements\n | Exclude<RuntimeRequirementsFor<P>, LayerOutput>\n | Exclude<AuthMethodExecutionRequirementsFor<P | AiProviders[number]>, LayerOutput>\n> => {\n const fullAuthMethodId = (providerId: string, method: AuthMethod.Any): string =>\n `${providerId}/${method.identifier}`;\n\n const findAuthMethod = (\n providerId: string,\n authMethodId: string,\n ): Effect.Effect<AuthMethod.Any, AuthMethodNotFoundError> => {\n const provider =\n pluginOf(app, providerId) ??\n app.aiProviders.find(candidate => AiProvider.registryId(candidate.identifier) === providerId);\n const method = provider?.authMethods.find(\n candidate =>\n candidate.identifier === authMethodId ||\n fullAuthMethodId(providerId, candidate) === authMethodId,\n );\n\n return method === undefined\n ? Effect.fail(new AuthMethodNotFoundError({ authMethodId, providerId }))\n : Effect.succeed(method);\n };\n\n const serviceLayer = Layer.effect(\n Service,\n Effect.gen(function* () {\n const channels = yield* AgentChannelRuntime.Service;\n const context = yield* Effect.context<\n RuntimeRequirementsFor<P> | AuthMethodExecutionRequirementsFor<P | AiProviders[number]>\n >();\n\n const appContext = indexGroups(context);\n\n const provideRuntimeContext = <A, E, R>(effect: Effect.Effect<A, E, R>) =>\n effect.pipe(Effect.updateContext(input => Context.merge(appContext, input)));\n\n // Requirements are satisfied by the context captured at layer build time;\n // the cast erases them so service methods expose closed effects.\n const runWithCapturedAppContext = <A, E>(\n effect: Effect.Effect<A, E, unknown>,\n ): Effect.Effect<A, E> => provideRuntimeContext(effect) as never;\n\n const getAuthMethod = (request: AuthMethodRequest) =>\n findAuthMethod(request.providerId, request.authMethodId);\n\n const getTrigger = (request: RuntimeTriggerLifecycleRequest) => {\n const resolved = resolveRuntimeTrigger(\n app.plugins,\n request.triggerId,\n request.triggerVersion,\n );\n return resolved === undefined ||\n (request.pluginKey !== undefined && resolved.providerId !== request.pluginKey)\n ? Effect.fail(new TriggerNotFoundError({ triggerId: request.triggerId }))\n : Effect.succeed(resolved);\n };\n\n const triggerLifecycleRequest = (\n request: RuntimeTriggerLifecycleRequest,\n ): Trigger.LifecycleRequest => ({\n config: request.config,\n ...(request.state === undefined ? {} : { state: request.state }),\n ...(request.connectionId === undefined ? {} : { connectionId: request.connectionId }),\n ...(request.context === undefined ? {} : { context: request.context }),\n });\n\n const webhookActivationRequest = (\n request: RuntimeWebhookActivationRequest,\n ): Trigger.WebhookActivationRequest => ({\n ...triggerLifecycleRequest(request),\n webhookUrl: request.webhookUrl,\n });\n\n // A host can pass the raw body as text; handlers verify signatures over its bytes.\n const webhookTriggerLifecycleRequest = (\n request: RuntimeWebhookTriggerLifecycleRequest,\n ): Trigger.WebhookExecutionRequest => ({\n ...webhookActivationRequest(request),\n request: Predicate.isString(request.request.rawBody)\n ? { ...request.request, rawBody: new TextEncoder().encode(request.request.rawBody) }\n : request.request,\n });\n\n const activateTrigger = (request: RuntimeWebhookActivationRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const entry = yield* getTrigger(request);\n return yield* Trigger.activate(entry, webhookActivationRequest(request));\n }),\n );\n\n const deactivateTrigger = (request: RuntimeWebhookActivationRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const entry = yield* getTrigger(request);\n return yield* Trigger.deactivate(entry, webhookActivationRequest(request));\n }),\n );\n\n const verifyTrigger = (request: RuntimeWebhookTriggerLifecycleRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const entry = yield* getTrigger(request);\n return yield* Trigger.verify(entry, webhookTriggerLifecycleRequest(request));\n }),\n );\n\n const parseTrigger = (request: RuntimeWebhookTriggerLifecycleRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const entry = yield* getTrigger(request);\n return yield* Trigger.parse(entry, webhookTriggerLifecycleRequest(request));\n }),\n );\n\n const pollTrigger = (request: RuntimeTriggerLifecycleRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const entry = yield* getTrigger(request);\n return yield* Trigger.poll(entry, triggerLifecycleRequest(request));\n }),\n );\n\n const decodeAuthMethodSetup = (request: DecodeAuthMethodSetupRequest) =>\n runWithCapturedAppContext(\n getAuthMethod(request).pipe(\n Effect.flatMap(method => {\n if (request.encoding === \"json\" && method.setup !== undefined) {\n return Schema.decodeUnknownEffect(Schema.toCodecJson(method.setup))(request.setup);\n }\n return AuthMethodExecution.decodeSetup(method, request.setup);\n }),\n ),\n );\n\n const withAuthMethodSetup = <A, E, R>(\n request: DecodeAuthMethodSetupRequest,\n execute: (\n method: AuthMethod.Any,\n setup: AuthMethod.Setup<AuthMethod.Any>,\n ) => Effect.Effect<A, E, R>,\n ) =>\n runWithCapturedAppContext(\n getAuthMethod(request).pipe(\n Effect.flatMap(method =>\n AuthMethodExecution.decodeSetup(method, request.setup).pipe(\n Effect.flatMap(setup => execute(method, setup)),\n ),\n ),\n ),\n );\n\n const prepareAuthMethod = (request: PrepareAuthMethodRequest) =>\n withAuthMethodSetup(request, (method, setup) =>\n AuthMethodExecution.prepare(method, request.input, { setup }),\n );\n\n const prepareOAuth2Tokens = (request: PrepareOAuth2TokensRequest) =>\n withAuthMethodSetup(request, (method, setup) =>\n AuthMethodExecution.prepareOAuth2Tokens(method, request.tokens, { setup }),\n );\n\n const refreshAuthMethod = (request: RefreshAuthMethodRequest) =>\n runWithCapturedAppContext(\n getAuthMethod(request).pipe(\n Effect.flatMap(method =>\n AuthMethodExecution.decodeSetup(method, request.setup).pipe(\n Effect.flatMap(setup =>\n AuthMethodExecution.refreshUnknown(method, request.material, {\n minValidityMs: request.minValidityMs,\n now: request.now,\n reason: request.reason,\n setup,\n }),\n ),\n ),\n ),\n ),\n );\n\n const resolveAuthMethod = (request: ResolveAuthMethodRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const method = yield* getAuthMethod(request);\n const setup = yield* decodeAuthMethodSetup(request);\n const value =\n request.encoding === \"json\"\n ? yield* AuthMethodExecution.resolveDecoded(\n method,\n yield* Schema.decodeUnknownEffect(Schema.toCodecJson(method.material))(\n request.material,\n ),\n { setup },\n )\n : yield* AuthMethodExecution.resolve(method, request.material, { setup });\n return AuthMethodBinding.makeBinding({\n connectionId: undefined,\n method,\n providerId: request.providerId,\n value,\n });\n }),\n );\n\n const resolveAiModelConfig = (request: ResolveAiModelConfigRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const provider = app.aiProviders.find(\n candidate => AiProvider.registryId(candidate.identifier) === request.providerId,\n );\n if (provider?.resolveRuntimeConfig === undefined) {\n return yield* new AiProviderRuntimeNotConfiguredError({\n providerId: request.providerId,\n });\n }\n const binding = yield* resolveAuthMethod(request);\n const allowed = provider.allowedModelIds?.(request.material);\n if (allowed !== undefined && !allowed.includes(request.model.id)) {\n return yield* new AiModelNotAllowedError({\n modelId: request.model.id,\n providerId: request.providerId,\n });\n }\n // SAFETY: the resolver belongs to this provider and the binding was\n // resolved from the same provider's declared auth-method list.\n const resolveRuntimeConfig =\n provider.resolveRuntimeConfig as AiProvider.RuntimeConfigResolver<\n readonly AuthMethod.Any[]\n >;\n return yield* Schema.decodeUnknownEffect(AiProvider.RuntimeConfig)(\n resolveRuntimeConfig({ binding, model: request.model }),\n );\n }),\n );\n\n const resolveSandboxAccess = (request: ResolveAuthMethodRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const access = pluginOf(app, request.providerId)?.sandboxAccess;\n if (access === undefined) {\n return yield* new SandboxAccessNotDeclaredError({ providerId: request.providerId });\n }\n const context = authRuntimeContext(yield* resolveAuthMethod(request));\n // Declared origins compare as URL origins, so `https://GHES.example:443` matches requests.\n const origins = Array.map(\n access.origins(context),\n origin => Result.getOrUndefined(Url.fromString(origin))?.origin ?? origin,\n );\n const authorize = (outgoing: HttpClientRequest.HttpClientRequest) => {\n const url = Result.getOrUndefined(Url.fromString(outgoing.url));\n const refused = new SandboxRequestNotAllowedError({\n origin: url?.origin ?? outgoing.url,\n path: url?.pathname ?? \"\",\n providerId: request.providerId,\n });\n if (url === undefined || !origins.includes(url.origin)) return Effect.fail(refused);\n return Effect.fromOption(access.authorize(outgoing, context), () => refused);\n };\n return { authorize, origins } satisfies ResolvedSandboxAccess;\n }),\n );\n\n return Service.of({\n activateTrigger,\n checkAccessAgentChannel: channels.checkAccess,\n deactivateTrigger,\n decodeAgentChannelDefinitionSettings: channels.decodeDefinitionSettings,\n decodeAgentChannelDeploymentSettings: channels.decodeDeploymentSettings,\n decodeAuthMethodSetup,\n executeAgentChannel: channels.execute,\n executeAuthJson: request =>\n runWithCapturedAppContext(\n pipe(\n getAuthMethod(request),\n Effect.flatMap(method => AuthMethodExecution.executeJson(method, request)),\n ),\n ),\n getAgentChannel: channels.get,\n getAuthMethod,\n invoke: request => runWithCapturedAppContext(invokeRaw(app, request)),\n invokeJson: request =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const result = yield* invokeRaw(app, request, true);\n return {\n ...result,\n data: yield* Schema.decodeUnknownEffect(Schema.Json)(result.data),\n };\n }),\n ),\n parseTrigger,\n pollTrigger,\n prepareAuthMethod,\n prepareOAuth2Tokens,\n refreshAuthMethod,\n allowedModelIdsFor: providerId =>\n app.aiProviders.find(\n provider => AiProvider.registryId(provider.identifier) === providerId,\n )?.allowedModelIds,\n resolveAiModelConfig,\n resolveAuthMethod,\n resolveSandboxAccess,\n verifyTrigger,\n });\n }),\n );\n\n return serviceLayer.pipe(\n Layer.provide(AgentChannelRuntime.layer(app.plugins.map(installation => installation.plugin))),\n Layer.provide(app.layer),\n );\n};\n\nexport * as DualRuntime from \"./DualRuntime.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GA,MAAa,WACX,QACA,aAC2B;CAAE;CAAQ;AAAQ;;;;;;;;AAS/C,MAAa,cACX,QACA,UAAU,aAQT;CACC,aAAa,CAAC;CACd,YAAY,OAAO;CACnB,OAAO,OAAO;CACd,SAAS,CAAC,QAAQ,QAAQ,OAAO,CAAC;AACpC;;;;;;;AAQF,MAAa,QAAQ,gBAAsE;CACzF,aAAa,CAAC;CACd;CACA,OAAO,MAAM;CACb,SAAS,CAAC;AACZ;AAkEA,SAAS,WAAW,KAAa,SAAyC;CACxE,MAAM,OAAO,IAAI,IAAI,MAAM,IAAI,IAAI,UAAS,iBAAgB,aAAa,OAAO,UAAU,CAAC;CAC3F,KAAK,MAAM,CAAC,WAAW,SAAS;EAC9B,IAAI,KAAK,IAAI,OAAO,UAAU,GAC5B,MAAM,IAAI,sBAAsB;GAC9B,WAAW;GACX,mBAAmB;GACnB,YAAY,OAAO;GACnB,iBAAiB,IAAI;GACrB,WAAW;EACb,CAAC;EAEH,KAAK,IAAI,OAAO,UAAU;CAC5B;CACA,OAAO;EACL,GAAG;EACH,OAAO,MAAM,OAAO,SAAS,IAAI,QAAQ,OAAO,CAAC,YAC/C,MAAM,aAAa,OAAO,OAAO,KAAK,CACxC;EACA,SAAS,CACP,GAAG,IAAI,SACP,GAAG,MAAM,IAAI,UAAU,CAAC,QAAQ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AC,CAAC,KAClB,MAAM,QAAQiB,MAA0B,IAAI,QAAQ,KAAI,iBAAgB,aAAa,MAAM,CAAC,CAAC,GAC7F,MAAM,QAAQ,IAAI,KAAK,CACzB;AACF"}
|
|
1
|
+
{"version":3,"file":"DualRuntime.js","names":["Func","AiProvider.registryId","AgentChannelRuntime.Service","Trigger.activate","Trigger.deactivate","Trigger.verify","Trigger.parse","Trigger.poll","AuthMethodExecution.decodeSetup","AuthMethodExecution.prepare","prepareOAuth2Tokens","AuthMethodExecution.prepareOAuth2Tokens","AuthMethodExecution.refreshUnknown","AuthMethodExecution.resolveDecoded","AuthMethodExecution.resolve","AuthMethodBinding.makeBinding","AiProvider.RuntimeConfig","AuthMethodExecution.executeJson","AgentChannelRuntime.layer"],"sources":["../src/DualRuntime.ts"],"sourcesContent":["/**\n * Dual action invocation, trigger lifecycle, and auth runtime.\n *\n * @since 0.0.0\n */\nimport {\n Array,\n Context,\n Effect,\n Function as Func,\n Layer,\n Predicate,\n Result,\n Schema,\n pipe,\n} from \"effect\";\n\nimport { type HttpClientRequest, Url } from \"effect/http\";\n\nimport {\n ActionHandlerError,\n RetryableActionHandlerError,\n type ActionHandlerFailure,\n} from \"./Action.ts\";\nimport * as AgentChannelRuntime from \"./AgentChannelRuntime.ts\";\nimport * as AiProvider from \"./AiProvider.ts\";\nimport type * as AuthMethod from \"./AuthMethod.ts\";\nimport * as AuthMethodBinding from \"./AuthMethodBinding.ts\";\nimport * as AuthMethodExecution from \"./AuthMethodExecution.ts\";\nimport {\n ConnectionIdNotAllowedError,\n ConnectionReauthorizationRequiredError,\n ConnectionRequiredError,\n ConnectionSelectionRequiredError,\n ConnectionResolverStoreError,\n InvalidConnectionIdError,\n InvalidResolvedConnectionError,\n type ConnectionResolutionContext,\n} from \"./ConnectionResolver.ts\";\nimport { BuilderCollisionError } from \"./DefinitionError.ts\";\nimport { TriggerNotFoundError } from \"./DualRegistry.ts\";\nimport { authRuntimeContext } from \"./internal/auth-execution.ts\";\nimport { resolveAction, type PluginActions } from \"./internal/dual/actions.ts\";\nimport {\n ActionNotFoundError,\n FieldIssue,\n InvalidActionInputError,\n InvalidActionOutputError,\n ActionHandlerNotFoundError,\n type InvokeError,\n type InvokeMeta,\n type InvokeRequest,\n type InvokeRequirementsFor,\n type InvokeSuccess,\n type PluginRequirements,\n invokeResolvedAction,\n invokeResolvedActionJson,\n} from \"./internal/dual/invoke.ts\";\nimport { resolveRuntimeTrigger } from \"./internal/dual/triggers.ts\";\nimport { indexGroups } from \"./internal/handler-context.ts\";\nimport type * as Plugin from \"./Plugin.ts\";\nimport * as Trigger from \"./Trigger.ts\";\n\n/**\n * One installed plugin release.\n *\n * @since 0.7.0\n * @category models\n */\nexport interface PluginInstallation<P extends Plugin.Any = Plugin.Any> {\n readonly plugin: P;\n /** The plugin's package version. */\n readonly version: string;\n}\n\n/**\n * The plugin releases and AI providers one runtime executes, with the services their handlers need.\n *\n * @since 0.7.0\n * @category models\n */\nexport interface App<\n out P extends Plugin.Any = Plugin.Any,\n LayerOutput = never,\n out LayerError = never,\n out LayerRequirements = never,\n out AiProviders extends readonly AiProvider.Any[] = readonly AiProvider.Any[],\n> {\n readonly identifier: string;\n readonly aiProviders: AiProviders;\n readonly plugins: readonly PluginInstallation<P>[];\n readonly layer: Layer.Layer<LayerOutput, LayerError, LayerRequirements>;\n}\n\n/**\n * Constraint type for working with any {@link App}.\n *\n * @since 0.7.0\n * @category type-level\n */\nexport interface AnyApp extends App<Plugin.Any, never, any, any, readonly AiProvider.Any[]> {}\n\n/**\n * Install one plugin release.\n *\n * @since 0.7.0\n * @category constructors\n */\nexport const install = <P extends Plugin.Any>(\n plugin: P,\n version: string,\n): PluginInstallation<P> => ({ plugin, version });\n\n/**\n * The runtime of one plugin release, as the plugin's own process runs it. `version` defaults to\n * `0.0.0` for tests that do not need the package version.\n *\n * @since 0.7.0\n * @category constructors\n */\nexport const fromPlugin = <const P extends Plugin.Any>(\n plugin: P,\n version = \"0.0.0\",\n): App<\n P,\n Plugin.LayerOutput<readonly [P]>,\n Plugin.LayerError<readonly [P]>,\n Plugin.LayerRequirements<readonly [P]>,\n readonly []\n> =>\n ({\n aiProviders: [],\n identifier: plugin.identifier,\n layer: plugin.layer,\n plugins: [install(plugin, version)],\n }) as never;\n\n/**\n * An app runtime without plugins, for {@link withPlugin} and {@link withPlugins} to fill.\n *\n * @since 0.7.0\n * @category constructors\n */\nexport const make = (identifier: string): App<never, never, never, never, readonly []> => ({\n aiProviders: [],\n identifier,\n layer: Layer.empty,\n plugins: [],\n});\n\ntype AppPlugin<A extends AnyApp> = A extends App<infer P, any, any, any, any> ? P : never;\ntype AppLayerOutput<A extends AnyApp> =\n A extends App<any, infer Output, any, any, any> ? Output : never;\ntype AppLayerError<A extends AnyApp> =\n A extends App<any, any, infer Error, any, any> ? Error : never;\ntype AppLayerRequirements<A extends AnyApp> =\n A extends App<any, any, any, infer Requirements, any> ? Requirements : never;\n\n/**\n * Result of adding a plugin release to an app runtime. A named interface keeps declaration emit\n * from expanding every plugin and layer member at large call sites.\n *\n * @since 0.7.0\n * @category type-level\n */\nexport interface WithPlugin<Self extends AnyApp, Added extends Plugin.Any> extends App<\n AppPlugin<Self> | Added,\n AppLayerOutput<Self> | Plugin.LayerOutput<readonly [Added]>,\n AppLayerError<Self> | Plugin.LayerError<readonly [Added]>,\n | Plugin.LayerRequirements<readonly [Added]>\n | Exclude<AppLayerRequirements<Self>, Plugin.LayerOutput<readonly [Added]>>,\n Self[\"aiProviders\"]\n // oxlint-disable-next-line typescript/no-empty-object-type -- TypeScript declaration emit expands a type alias at every app call site (TS7056).\n> {}\n\n// Match the runtime's left-to-right provideMerge fold: later plugins can\n// satisfy earlier requirements, but earlier outputs cannot satisfy later ones.\ntype BulkLayerRequirements<\n Added extends readonly Plugin.Any[],\n Requirements,\n> = number extends Added[\"length\"]\n ? Requirements | Layer.Services<Added[number][\"layer\"]>\n : Added extends readonly [\n infer Head extends Plugin.Any,\n ...infer Tail extends readonly Plugin.Any[],\n ]\n ? BulkLayerRequirements<\n Tail,\n Layer.Services<Head[\"layer\"]> | Exclude<Requirements, Layer.Success<Head[\"layer\"]>>\n >\n : Requirements;\n\n/**\n * Result of adding several plugin releases to an app runtime in one step.\n *\n * @since 0.7.0\n * @category type-level\n */\nexport interface WithPlugins<Self extends AnyApp, Added extends readonly Plugin.Any[]> extends App<\n AppPlugin<Self> | Added[number],\n AppLayerOutput<Self> | Layer.Success<Added[number][\"layer\"]>,\n AppLayerError<Self> | Layer.Error<Added[number][\"layer\"]>,\n BulkLayerRequirements<Added, AppLayerRequirements<Self>>,\n Self[\"aiProviders\"]\n // oxlint-disable-next-line typescript/no-empty-object-type -- TypeScript declaration emit expands a type alias at every app call site (TS7056).\n> {}\n\n/** A plugin and the package version of its release. */\ntype PluginEntry = readonly [plugin: Plugin.Any, version: string];\n\ntype PluginsOf<Entries extends readonly PluginEntry[]> = {\n readonly [K in keyof Entries]: Entries[K][0];\n};\n\nfunction addPlugins(app: AnyApp, entries: readonly PluginEntry[]): AnyApp {\n const seen = new Set(Array.map(app.plugins, installation => installation.plugin.identifier));\n for (const [plugin] of entries) {\n if (seen.has(plugin.identifier)) {\n throw new BuilderCollisionError({\n childKind: \"plugin\",\n existingChildKind: \"plugin\",\n identifier: plugin.identifier,\n ownerIdentifier: app.identifier,\n ownerKind: \"dual\",\n });\n }\n seen.add(plugin.identifier);\n }\n return {\n ...app,\n layer: Array.reduce(entries, app.layer, (layer, [plugin]) =>\n Layer.provideMerge(layer, plugin.layer),\n ),\n plugins: [\n ...app.plugins,\n ...Array.map(entries, ([plugin, version]) => install(plugin, version)),\n ],\n };\n}\n\n/**\n * Add one plugin release: the plugin and its package version.\n *\n * @since 0.7.0\n * @category combinators\n */\nexport const withPlugin: {\n <const P extends Plugin.Any>(\n plugin: P,\n version: string,\n ): <Self extends AnyApp>(app: Self) => WithPlugin<Self, P>;\n <Self extends AnyApp, const P extends Plugin.Any>(\n app: Self,\n plugin: P,\n version: string,\n ): WithPlugin<Self, P>;\n} = Func.dual(3, (app: AnyApp, plugin: Plugin.Any, version: string) =>\n addPlugins(app, [[plugin, version]]),\n);\n\n/**\n * Add several plugin releases in one step, which keeps a large app's inferred type compact.\n *\n * @since 0.7.0\n * @category combinators\n */\nexport const withPlugins: {\n <const E extends readonly PluginEntry[]>(\n entries: E,\n ): <Self extends AnyApp>(app: Self) => WithPlugins<Self, PluginsOf<E>>;\n <Self extends AnyApp, const E extends readonly PluginEntry[]>(\n app: Self,\n entries: E,\n ): WithPlugins<Self, PluginsOf<E>>;\n} = Func.dual(2, addPlugins);\n\nconst pluginOf = (app: AnyApp, identifier: string): Plugin.Any | undefined =>\n app.plugins.find(installation => installation.plugin.identifier === identifier)?.plugin;\n\n/**\n * Request payload accepted by {@link invoke}.\n *\n * @since 0.0.0\n * @category models\n */\nexport type { InvokeRequest };\n\n/**\n * Metadata returned alongside successful invocation data.\n *\n * @since 0.0.0\n * @category models\n */\nexport type { InvokeMeta };\n\n/**\n * Successful invocation envelope returned by {@link invoke}.\n *\n * @since 0.0.0\n * @category models\n */\nexport type { InvokeSuccess };\n\n/**\n * Structured field-level validation issue surfaced by {@link InvalidActionInputError}.\n *\n * @since 0.0.0\n * @category models\n */\nexport { FieldIssue };\n\n/**\n * Raised when an invocation references an unknown action id.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ActionNotFoundError };\n\n/**\n * @since 0.0.0\n * @category errors\n */\n\n/**\n * Raised when invocation input fails schema validation.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { InvalidActionInputError };\n\n/**\n * Raised when action handler output fails schema validation.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { InvalidActionOutputError };\n\n/**\n * Raised when the runtime action handler service is missing.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ActionHandlerNotFoundError };\n\n/**\n * Non-retryable failure reported by a trusted action handler.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ActionHandlerError };\n\n/**\n * Retryable failure reported by a trusted action handler.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { RetryableActionHandlerError };\n\n/**\n * Stable trusted action handler failure contract.\n *\n * @since 0.0.0\n * @category errors\n */\nexport type { ActionHandlerFailure };\n\n/**\n * Raised when an action does not accept a connection but a connectionId was still provided.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ConnectionIdNotAllowedError };\n\n/**\n * Raised when invocation requires a connection and no compatible binding is available.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ConnectionRequiredError };\n\n/**\n * Raised when several compatible connection bindings exist and the caller must choose one.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ConnectionSelectionRequiredError };\n\n/**\n * Raised when the provider refuses a connection's stored grant and the user must sign in again.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ConnectionReauthorizationRequiredError };\n\n/**\n * Raised when the host connection store is unavailable.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { ConnectionResolverStoreError };\n\n/**\n * Raised when a connectionId does not resolve to a compatible binding.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { InvalidConnectionIdError };\n\n/**\n * Raised when a resolved connection binding does not satisfy its auth method schema.\n *\n * @since 0.0.0\n * @category errors\n */\nexport { InvalidResolvedConnectionError };\n\n/**\n * Structured SDK-owned invocation failures.\n *\n * @since 0.0.0\n * @category errors\n */\nexport type { InvokeError };\nexport type { InvokeRequirementsFor };\n\n/**\n * Invoke an action directly in-process.\n *\n * The invocation boundary resolves an action by canonical machine id, validates\n * unknown input against the resolved runtime schema, runs the handler, and\n * returns a standard success envelope. This mirrors the server trusted invoke\n * boundary: runtime schema validation is authoritative.\n *\n * @since 0.0.0\n * @category execution\n */\nconst failInvokeActionNotFound = (\n actionId: string,\n): Effect.Effect<InvokeSuccess, ActionNotFoundError> =>\n Effect.fail(new ActionNotFoundError({ actionId }));\n\nconst invokeRaw = <\n const P extends Plugin.Any,\n LayerOutput,\n LayerError,\n LayerRequirements,\n const AiProviders extends readonly AiProvider.Any[],\n>(\n app: App<P, LayerOutput, LayerError, LayerRequirements, AiProviders>,\n request: InvokeRequest,\n json = false,\n): Effect.Effect<InvokeSuccess, InvokeError, RuntimeRequirementsFor<P>> => {\n const resolved = resolveAction(app.plugins, request.actionId, request.actionVersion);\n\n if (\n resolved === undefined ||\n (request.pluginKey !== undefined && resolved.providerId !== request.pluginKey)\n ) {\n return failInvokeActionNotFound(request.actionId);\n }\n\n // The runtime entry is resolved from erased plugin trees, so the precise\n // per-action requirement union in the return annotation cannot be recovered\n // here; the annotation is the contract, the cast is the boundary.\n return (json ? invokeResolvedActionJson : invokeResolvedAction)(\n resolved.providerId,\n resolved.actionId,\n resolved.pluginVersion,\n resolved.action,\n resolved.authMethods,\n request,\n ) as never;\n};\n\nexport const invoke = <\n const P extends Plugin.Any,\n LayerOutput,\n LayerError,\n LayerRequirements,\n const AiProviders extends readonly AiProvider.Any[],\n>(\n app: App<P, LayerOutput, LayerError, LayerRequirements, AiProviders>,\n request: InvokeRequest,\n): Effect.Effect<\n InvokeSuccess,\n InvokeError | LayerError,\n LayerRequirements | Exclude<RuntimeRequirementsFor<P>, LayerOutput>\n> => invokeRaw(app, request).pipe(Effect.provide(app.layer));\n\n/**\n * Runtime-first invocation request accepted by {@link Service}.\n *\n * @since 0.0.0\n * @category models\n */\nexport type RuntimeInvokeRequest = InvokeRequest;\n\n/**\n * Runtime-first trigger lifecycle request accepted by {@link Service}.\n *\n * @since 0.0.0\n * @category models\n */\nexport interface RuntimeTriggerLifecycleRequest {\n readonly triggerId: string;\n readonly pluginKey?: string;\n /** The exact plugin release the caller pinned; another installed release does not run. */\n readonly triggerVersion?: string | undefined;\n readonly config: unknown;\n readonly state?: unknown | undefined;\n readonly connectionId?: string | undefined;\n readonly context?: ConnectionResolutionContext | undefined;\n}\n\nexport interface RuntimeWebhookActivationRequest extends RuntimeTriggerLifecycleRequest {\n readonly webhookUrl: string;\n}\n\nexport interface RuntimeWebhookTriggerLifecycleRequest extends RuntimeWebhookActivationRequest {\n readonly request: Trigger.WebhookRequest;\n}\n\nexport interface AuthMethodRequest {\n readonly providerId: string;\n readonly authMethodId: string;\n}\n\nexport interface DecodeAuthMethodSetupRequest extends AuthMethodRequest {\n readonly encoding?: \"json\";\n readonly setup: unknown;\n}\n\nexport interface PrepareAuthMethodRequest extends AuthMethodRequest {\n readonly input: unknown;\n readonly setup: unknown;\n}\n\nexport interface PrepareOAuth2TokensRequest extends AuthMethodRequest {\n readonly tokens: AuthMethod.OAuth2TokenResponse;\n readonly setup: unknown;\n}\n\nexport interface RefreshAuthMethodRequest extends AuthMethodRequest {\n readonly material: unknown;\n readonly setup: unknown;\n readonly now: number;\n readonly minValidityMs: number;\n readonly reason: AuthMethod.RefreshReason;\n}\n\nexport interface ResolveAuthMethodRequest extends AuthMethodRequest {\n /** `json` when the material and setup arrive in their canonical JSON encoding, as in the sandbox. */\n readonly encoding?: \"json\";\n readonly material: unknown;\n readonly setup: unknown;\n}\n\nexport interface ResolveAiModelConfigRequest extends ResolveAuthMethodRequest {\n readonly model: AiProvider.RuntimeModel;\n}\n\nexport class AuthMethodNotFoundError extends Schema.TaggedError<AuthMethodNotFoundError>()(\n \"AuthMethodNotFoundError\",\n { authMethodId: Schema.String, providerId: Schema.String },\n) {}\n\nexport type AuthMethodExecutionError =\n | AuthMethodNotFoundError\n | Schema.SchemaError\n | AuthMethod.ExpectedOAuth2MethodError\n | AuthMethod.OAuth2RefreshTokenUnavailableError\n | AuthMethod.AuthMethodHookError;\n\nexport class AiProviderRuntimeNotConfiguredError extends Schema.TaggedError<AiProviderRuntimeNotConfiguredError>()(\n \"AiProviderRuntimeNotConfiguredError\",\n { providerId: Schema.String },\n) {}\n\nexport class AiModelNotAllowedError extends Schema.TaggedError<AiModelNotAllowedError>()(\n \"AiModelNotAllowedError\",\n { modelId: Schema.String, providerId: Schema.String },\n) {}\n\nexport type AiModelConfigError =\n | AuthMethodExecutionError\n | AiProviderRuntimeNotConfiguredError\n | AiModelNotAllowedError;\n\n/** Raised when a provider declares no sandbox access. */\nexport class SandboxAccessNotDeclaredError extends Schema.TaggedError<SandboxAccessNotDeclaredError>()(\n \"SandboxAccessNotDeclaredError\",\n { providerId: Schema.String },\n) {}\n\n/** Raised when the Connection may not be sent with a sandbox request: another origin, or a request the provider refuses. */\nexport class SandboxRequestNotAllowedError extends Schema.TaggedError<SandboxRequestNotAllowedError>()(\n \"SandboxRequestNotAllowedError\",\n { origin: Schema.String, path: Schema.String, providerId: Schema.String },\n) {}\n\nexport type SandboxAccessError = AuthMethodExecutionError | SandboxAccessNotDeclaredError;\n\n/** One Connection's sandbox access: where its credential may go, and how a request gets it. */\nexport interface ResolvedSandboxAccess {\n readonly origins: readonly string[];\n readonly authorize: (\n request: HttpClientRequest.HttpClientRequest,\n ) => Effect.Effect<HttpClientRequest.HttpClientRequest, SandboxRequestNotAllowedError>;\n}\n\n/**\n * Runtime service materialized from an {@link App}.\n *\n * @since 0.0.0\n * @category services\n */\nexport interface RuntimeService {\n readonly executeAuthJson: (\n request: AuthMethodExecution.JsonRequest,\n ) => Effect.Effect<unknown, AuthMethodExecutionError>;\n readonly invokeJson: (\n request: RuntimeInvokeRequest,\n ) => Effect.Effect<InvokeSuccess<string, Schema.Json>, InvokeError | Schema.SchemaError>;\n readonly decodeAgentChannelDefinitionSettings: AgentChannelRuntime.Interface[\"decodeDefinitionSettings\"];\n readonly decodeAgentChannelDeploymentSettings: AgentChannelRuntime.Interface[\"decodeDeploymentSettings\"];\n readonly getAgentChannel: AgentChannelRuntime.Interface[\"get\"];\n readonly checkAccessAgentChannel: AgentChannelRuntime.Interface[\"checkAccess\"];\n readonly executeAgentChannel: AgentChannelRuntime.Interface[\"execute\"];\n readonly invoke: (request: RuntimeInvokeRequest) => Effect.Effect<InvokeSuccess, InvokeError>;\n readonly activateTrigger: (\n request: RuntimeWebhookActivationRequest,\n ) => Effect.Effect<Trigger.ActivateSuccess, unknown>;\n readonly deactivateTrigger: (\n request: RuntimeWebhookActivationRequest,\n ) => Effect.Effect<Trigger.DeactivateSuccess, unknown>;\n readonly verifyTrigger: (\n request: RuntimeWebhookTriggerLifecycleRequest,\n ) => Effect.Effect<Trigger.VerifySuccess, unknown>;\n readonly parseTrigger: (\n request: RuntimeWebhookTriggerLifecycleRequest,\n ) => Effect.Effect<Trigger.EmittedEventsSuccess<string, \"parse\">, unknown>;\n readonly pollTrigger: (\n request: RuntimeTriggerLifecycleRequest,\n ) => Effect.Effect<Trigger.EmittedEventsSuccess<string, \"poll\">, unknown>;\n readonly getAuthMethod: (\n request: AuthMethodRequest,\n ) => Effect.Effect<AuthMethod.Any, AuthMethodNotFoundError>;\n // TODO(live-schema-validation): expose live action/trigger schema decoders by capability version.\n // Server authoring/runtime must validate against SDK declarations, not JSON Schema projections.\n readonly decodeAuthMethodSetup: (\n request: DecodeAuthMethodSetupRequest,\n ) => Effect.Effect<unknown, AuthMethodExecutionError>;\n readonly prepareAuthMethod: (\n request: PrepareAuthMethodRequest,\n ) => Effect.Effect<unknown, AuthMethodExecutionError>;\n readonly prepareOAuth2Tokens: (\n request: PrepareOAuth2TokensRequest,\n ) => Effect.Effect<unknown, AuthMethodExecutionError>;\n readonly refreshAuthMethod: (\n request: RefreshAuthMethodRequest,\n ) => Effect.Effect<unknown | undefined, AuthMethodExecutionError>;\n readonly resolveAuthMethod: (\n request: ResolveAuthMethodRequest,\n ) => Effect.Effect<AuthMethodBinding.Binding, AuthMethodExecutionError>;\n readonly allowedModelIdsFor: (providerId: string) => AiProvider.AllowedModelIds | undefined;\n readonly resolveAiModelConfig: (\n request: ResolveAiModelConfigRequest,\n ) => Effect.Effect<AiProvider.RuntimeConfig, AiModelConfigError>;\n readonly resolveSandboxAccess: (\n request: ResolveAuthMethodRequest,\n ) => Effect.Effect<ResolvedSandboxAccess, SandboxAccessError>;\n}\n\n/**\n * Effect service provided by {@link toLayer}.\n *\n * @since 0.0.0\n * @category services\n */\nexport class Service extends Context.Service<Service, RuntimeService>()(\n \"@dual-os/sdk/Dual/Service\",\n) {}\n\nexport type RuntimeRequirementsFor<P extends Plugin.Any> =\n | AgentChannelRuntime.Requirements<P>\n | (P extends Plugin.Any ? PluginRequirements<P, PluginActions<P>> : never);\n\ntype AuthProvider = Plugin.Any | AiProvider.Any;\n\ntype AuthMethodFor<Providers extends AuthProvider> = Providers[\"authMethods\"][number];\n\ntype AuthMethodSetupDecodeRequirements<Method extends AuthMethod.Any> =\n AuthMethod.SetupSchema<Method> extends Schema.Top\n ? Schema.Codec.DecodingServices<AuthMethod.SetupSchema<Method>>\n : never;\n\ntype AuthMethodInputDecodeRequirements<Method extends AuthMethod.Any> =\n AuthMethod.InputSchema<Method> extends Schema.Top\n ? Schema.Codec.DecodingServices<AuthMethod.InputSchema<Method>>\n : never;\n\ntype AuthMethodExecutionRequirementsFor<Providers extends AuthProvider> =\n AuthMethodFor<Providers> extends infer Method\n ? Method extends AuthMethod.Any\n ? | AuthMethod.Requirements<Method>\n | AuthMethodSetupDecodeRequirements<Method>\n | AuthMethodInputDecodeRequirements<Method>\n | Schema.Codec.DecodingServices<AuthMethod.MaterialSchema<Method>>\n | Schema.Codec.DecodingServices<AuthMethod.ValueSchema<Method>>\n | Schema.Codec.EncodingServices<AuthMethod.MaterialSchema<Method>>\n | Schema.Codec.EncodingServices<AuthMethod.ValueSchema<Method>>\n | (AuthMethod.SetupSchema<Method> extends Schema.Top\n ? Schema.Codec.EncodingServices<AuthMethod.SetupSchema<Method>>\n : never)\n : never\n : never;\n\n/**\n * Requirements still needed by {@link toLayer} for an app.\n *\n * Hosts (the server, a worker, a test harness) never know an app's concrete\n * implementations: they talk to it exclusively through the generic\n * {@link Service} layer. App-specific dependencies — a plugin's API client, an\n * auth hook's token service — are discharged where they are known, at the\n * plugin or app definition (the `Exclude<..., LayerOutput>` below cancels\n * them). Only what the definition did not discharge surfaces here,\n * generically, and the host entrypoint forces it to `never` before anything\n * runs.\n *\n * @since 0.0.0\n * @category type-level\n */\nexport type ToLayerRequirements<A extends AnyApp> =\n A extends App<\n infer P extends Plugin.Any,\n infer LayerOutput,\n any,\n infer LayerRequirements,\n infer AiProviders extends readonly AiProvider.Any[]\n >\n ? | LayerRequirements\n | Exclude<RuntimeRequirementsFor<P>, LayerOutput>\n | Exclude<AuthMethodExecutionRequirementsFor<P | AiProviders[number]>, LayerOutput>\n : never;\n\n/**\n * Layer-construction errors surfaced by {@link toLayer} for an app.\n *\n * @since 0.0.0\n * @category type-level\n */\nexport type ToLayerError<A extends AnyApp> =\n A extends App<any, any, infer LayerError, any, any> ? LayerError : never;\n\n/**\n * Turn an {@link App} into a runtime Effect service layer.\n *\n * @since 0.0.0\n * @category layers\n */\nexport const toLayer = <\n const P extends Plugin.Any,\n LayerOutput,\n LayerError,\n LayerRequirements,\n const AiProviders extends readonly AiProvider.Any[],\n>(\n app: App<P, LayerOutput, LayerError, LayerRequirements, AiProviders>,\n): Layer.Layer<\n Service,\n LayerError,\n | LayerRequirements\n | Exclude<RuntimeRequirementsFor<P>, LayerOutput>\n | Exclude<AuthMethodExecutionRequirementsFor<P | AiProviders[number]>, LayerOutput>\n> => {\n const fullAuthMethodId = (providerId: string, method: AuthMethod.Any): string =>\n `${providerId}/${method.identifier}`;\n\n const findAuthMethod = (\n providerId: string,\n authMethodId: string,\n ): Effect.Effect<AuthMethod.Any, AuthMethodNotFoundError> => {\n const provider =\n pluginOf(app, providerId) ??\n app.aiProviders.find(candidate => AiProvider.registryId(candidate.identifier) === providerId);\n const method = provider?.authMethods.find(\n candidate =>\n candidate.identifier === authMethodId ||\n fullAuthMethodId(providerId, candidate) === authMethodId,\n );\n\n return method === undefined\n ? Effect.fail(new AuthMethodNotFoundError({ authMethodId, providerId }))\n : Effect.succeed(method);\n };\n\n const serviceLayer = Layer.effect(\n Service,\n Effect.gen(function* () {\n const channels = yield* AgentChannelRuntime.Service;\n const context = yield* Effect.context<\n RuntimeRequirementsFor<P> | AuthMethodExecutionRequirementsFor<P | AiProviders[number]>\n >();\n\n const appContext = indexGroups(context);\n\n const provideRuntimeContext = <A, E, R>(effect: Effect.Effect<A, E, R>) =>\n effect.pipe(Effect.updateContext(input => Context.merge(appContext, input)));\n\n // Requirements are satisfied by the context captured at layer build time;\n // the cast erases them so service methods expose closed effects.\n const runWithCapturedAppContext = <A, E>(\n effect: Effect.Effect<A, E, unknown>,\n ): Effect.Effect<A, E> => provideRuntimeContext(effect) as never;\n\n const getAuthMethod = (request: AuthMethodRequest) =>\n findAuthMethod(request.providerId, request.authMethodId);\n\n const getTrigger = (request: RuntimeTriggerLifecycleRequest) => {\n const resolved = resolveRuntimeTrigger(\n app.plugins,\n request.triggerId,\n request.triggerVersion,\n );\n return resolved === undefined ||\n (request.pluginKey !== undefined && resolved.providerId !== request.pluginKey)\n ? Effect.fail(new TriggerNotFoundError({ triggerId: request.triggerId }))\n : Effect.succeed(resolved);\n };\n\n const triggerLifecycleRequest = (\n request: RuntimeTriggerLifecycleRequest,\n ): Trigger.LifecycleRequest => ({\n config: request.config,\n ...(request.state === undefined ? {} : { state: request.state }),\n ...(request.connectionId === undefined ? {} : { connectionId: request.connectionId }),\n ...(request.context === undefined ? {} : { context: request.context }),\n });\n\n const webhookActivationRequest = (\n request: RuntimeWebhookActivationRequest,\n ): Trigger.WebhookActivationRequest => ({\n ...triggerLifecycleRequest(request),\n webhookUrl: request.webhookUrl,\n });\n\n // A host can pass the raw body as text; handlers verify signatures over its bytes.\n const webhookTriggerLifecycleRequest = (\n request: RuntimeWebhookTriggerLifecycleRequest,\n ): Trigger.WebhookExecutionRequest => ({\n ...webhookActivationRequest(request),\n request: Predicate.isString(request.request.rawBody)\n ? { ...request.request, rawBody: new TextEncoder().encode(request.request.rawBody) }\n : request.request,\n });\n\n const activateTrigger = (request: RuntimeWebhookActivationRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const entry = yield* getTrigger(request);\n return yield* Trigger.activate(entry, webhookActivationRequest(request));\n }),\n );\n\n const deactivateTrigger = (request: RuntimeWebhookActivationRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const entry = yield* getTrigger(request);\n return yield* Trigger.deactivate(entry, webhookActivationRequest(request));\n }),\n );\n\n const verifyTrigger = (request: RuntimeWebhookTriggerLifecycleRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const entry = yield* getTrigger(request);\n return yield* Trigger.verify(entry, webhookTriggerLifecycleRequest(request));\n }),\n );\n\n const parseTrigger = (request: RuntimeWebhookTriggerLifecycleRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const entry = yield* getTrigger(request);\n return yield* Trigger.parse(entry, webhookTriggerLifecycleRequest(request));\n }),\n );\n\n const pollTrigger = (request: RuntimeTriggerLifecycleRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const entry = yield* getTrigger(request);\n return yield* Trigger.poll(entry, triggerLifecycleRequest(request));\n }),\n );\n\n const decodeAuthMethodSetup = (request: DecodeAuthMethodSetupRequest) =>\n runWithCapturedAppContext(\n getAuthMethod(request).pipe(\n Effect.flatMap(method => {\n if (request.encoding === \"json\" && method.setup !== undefined) {\n return Schema.decodeUnknownEffect(Schema.toCodecJson(method.setup))(request.setup);\n }\n return AuthMethodExecution.decodeSetup(method, request.setup);\n }),\n ),\n );\n\n const withAuthMethodSetup = <A, E, R>(\n request: DecodeAuthMethodSetupRequest,\n execute: (\n method: AuthMethod.Any,\n setup: AuthMethod.Setup<AuthMethod.Any>,\n ) => Effect.Effect<A, E, R>,\n ) =>\n runWithCapturedAppContext(\n getAuthMethod(request).pipe(\n Effect.flatMap(method =>\n AuthMethodExecution.decodeSetup(method, request.setup).pipe(\n Effect.flatMap(setup => execute(method, setup)),\n ),\n ),\n ),\n );\n\n const prepareAuthMethod = (request: PrepareAuthMethodRequest) =>\n withAuthMethodSetup(request, (method, setup) =>\n AuthMethodExecution.prepare(method, request.input, { setup }),\n );\n\n const prepareOAuth2Tokens = (request: PrepareOAuth2TokensRequest) =>\n withAuthMethodSetup(request, (method, setup) =>\n AuthMethodExecution.prepareOAuth2Tokens(method, request.tokens, { setup }),\n );\n\n const refreshAuthMethod = (request: RefreshAuthMethodRequest) =>\n runWithCapturedAppContext(\n getAuthMethod(request).pipe(\n Effect.flatMap(method =>\n AuthMethodExecution.decodeSetup(method, request.setup).pipe(\n Effect.flatMap(setup =>\n AuthMethodExecution.refreshUnknown(method, request.material, {\n minValidityMs: request.minValidityMs,\n now: request.now,\n reason: request.reason,\n setup,\n }),\n ),\n ),\n ),\n ),\n );\n\n const resolveAuthMethod = (request: ResolveAuthMethodRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const method = yield* getAuthMethod(request);\n const setup = yield* decodeAuthMethodSetup(request);\n const value =\n request.encoding === \"json\"\n ? yield* AuthMethodExecution.resolveDecoded(\n method,\n yield* Schema.decodeUnknownEffect(Schema.toCodecJson(method.material))(\n request.material,\n ),\n { setup },\n )\n : yield* AuthMethodExecution.resolve(method, request.material, { setup });\n return AuthMethodBinding.makeBinding({\n connectionId: undefined,\n method,\n providerId: request.providerId,\n value,\n });\n }),\n );\n\n const resolveAiModelConfig = (request: ResolveAiModelConfigRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const provider = app.aiProviders.find(\n candidate => AiProvider.registryId(candidate.identifier) === request.providerId,\n );\n if (provider?.resolveRuntimeConfig === undefined) {\n return yield* new AiProviderRuntimeNotConfiguredError({\n providerId: request.providerId,\n });\n }\n const binding = yield* resolveAuthMethod(request);\n const allowed = provider.allowedModelIds?.(request.material);\n if (allowed !== undefined && !allowed.includes(request.model.id)) {\n return yield* new AiModelNotAllowedError({\n modelId: request.model.id,\n providerId: request.providerId,\n });\n }\n // SAFETY: the resolver belongs to this provider and the binding was\n // resolved from the same provider's declared auth-method list.\n const resolveRuntimeConfig =\n provider.resolveRuntimeConfig as AiProvider.RuntimeConfigResolver<\n readonly AuthMethod.Any[]\n >;\n return yield* Schema.decodeUnknownEffect(AiProvider.RuntimeConfig)(\n resolveRuntimeConfig({ binding, model: request.model }),\n );\n }),\n );\n\n const resolveSandboxAccess = (request: ResolveAuthMethodRequest) =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const access = pluginOf(app, request.providerId)?.sandboxAccess;\n if (access === undefined) {\n return yield* new SandboxAccessNotDeclaredError({ providerId: request.providerId });\n }\n const context = authRuntimeContext(yield* resolveAuthMethod(request));\n // Declared origins compare as URL origins, so `https://GHES.example:443` matches requests.\n const origins = Array.map(\n access.origins(context),\n origin => Result.getOrUndefined(Url.fromString(origin))?.origin ?? origin,\n );\n const authorize = (outgoing: HttpClientRequest.HttpClientRequest) => {\n const url = Result.getOrUndefined(Url.fromString(outgoing.url));\n const refused = new SandboxRequestNotAllowedError({\n origin: url?.origin ?? outgoing.url,\n path: url?.pathname ?? \"\",\n providerId: request.providerId,\n });\n if (url === undefined || !origins.includes(url.origin)) return Effect.fail(refused);\n return Effect.fromOption(access.authorize(outgoing, context), () => refused);\n };\n return { authorize, origins } satisfies ResolvedSandboxAccess;\n }),\n );\n\n return Service.of({\n activateTrigger,\n checkAccessAgentChannel: channels.checkAccess,\n deactivateTrigger,\n decodeAgentChannelDefinitionSettings: channels.decodeDefinitionSettings,\n decodeAgentChannelDeploymentSettings: channels.decodeDeploymentSettings,\n decodeAuthMethodSetup,\n executeAgentChannel: channels.execute,\n executeAuthJson: request =>\n runWithCapturedAppContext(\n pipe(\n getAuthMethod(request),\n Effect.flatMap(method => AuthMethodExecution.executeJson(method, request)),\n ),\n ),\n getAgentChannel: channels.get,\n getAuthMethod,\n invoke: request => runWithCapturedAppContext(invokeRaw(app, request)),\n invokeJson: request =>\n runWithCapturedAppContext(\n Effect.gen(function* () {\n const result = yield* invokeRaw(app, request, true);\n return {\n ...result,\n data: yield* Schema.decodeUnknownEffect(Schema.Json)(result.data),\n };\n }),\n ),\n parseTrigger,\n pollTrigger,\n prepareAuthMethod,\n prepareOAuth2Tokens,\n refreshAuthMethod,\n allowedModelIdsFor: providerId =>\n app.aiProviders.find(\n provider => AiProvider.registryId(provider.identifier) === providerId,\n )?.allowedModelIds,\n resolveAiModelConfig,\n resolveAuthMethod,\n resolveSandboxAccess,\n verifyTrigger,\n });\n }),\n );\n\n return serviceLayer.pipe(\n Layer.provide(AgentChannelRuntime.layer(app.plugins.map(installation => installation.plugin))),\n Layer.provide(app.layer),\n );\n};\n\nexport * as DualRuntime from \"./DualRuntime.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GA,MAAa,WACX,QACA,aAC2B;CAAE;CAAQ;AAAQ;;;;;;;;AAS/C,MAAa,cACX,QACA,UAAU,aAQT;CACC,aAAa,CAAC;CACd,YAAY,OAAO;CACnB,OAAO,OAAO;CACd,SAAS,CAAC,QAAQ,QAAQ,OAAO,CAAC;AACpC;;;;;;;AAQF,MAAa,QAAQ,gBAAsE;CACzF,aAAa,CAAC;CACd;CACA,OAAO,MAAM;CACb,SAAS,CAAC;AACZ;AAkEA,SAAS,WAAW,KAAa,SAAyC;CACxE,MAAM,OAAO,IAAI,IAAI,MAAM,IAAI,IAAI,UAAS,iBAAgB,aAAa,OAAO,UAAU,CAAC;CAC3F,KAAK,MAAM,CAAC,WAAW,SAAS;EAC9B,IAAI,KAAK,IAAI,OAAO,UAAU,GAC5B,MAAM,IAAI,sBAAsB;GAC9B,WAAW;GACX,mBAAmB;GACnB,YAAY,OAAO;GACnB,iBAAiB,IAAI;GACrB,WAAW;EACb,CAAC;EAEH,KAAK,IAAI,OAAO,UAAU;CAC5B;CACA,OAAO;EACL,GAAG;EACH,OAAO,MAAM,OAAO,SAAS,IAAI,QAAQ,OAAO,CAAC,YAC/C,MAAM,aAAa,OAAO,OAAO,KAAK,CACxC;EACA,SAAS,CACP,GAAG,IAAI,SACP,GAAG,MAAM,IAAI,UAAU,CAAC,QAAQ,aAAa,QAAQ,QAAQ,OAAO,CAAC,CACvE;CACF;AACF;;;;;;;AAQA,MAAa,aAUTA,SAAK,KAAK,IAAI,KAAa,QAAoB,YACjD,WAAW,KAAK,CAAC,CAAC,QAAQ,O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.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Any as Any$1 } from "./Action.js";
|
|
2
|
-
import { Any as Any$2 } from "./Trigger.js";
|
|
3
2
|
import { FilterChildren } from "./internal/children.js";
|
|
3
|
+
import { Any as Any$2 } from "./Trigger.js";
|
|
4
4
|
import { Pipeable } from "effect";
|
|
5
5
|
declare namespace Group_d_exports {
|
|
6
6
|
export { ActionsFromChildren, AddChildren, Any, Group, GroupOptions, GroupsFromChildren, StructuralChild, TriggersFromChildren, TypeId, add, isGroup, make, withAction, withActions, withDescription, withGroup, withGroups, withName, withTrigger, withTriggers };
|
package/dist/Group.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { assertUniqueMixedChildIdentifiers, assertUniqueStructuralChildIdentifiers, partitionChildren } from "./internal/children.js";
|
|
3
|
+
import { appendElements } from "./internal/collection-utils.js";
|
|
2
4
|
import { validateIdentifier } from "./internal/identifier.js";
|
|
3
5
|
import { PipeableProto } from "./internal/proto.js";
|
|
4
|
-
import { appendElements } from "./internal/collection-utils.js";
|
|
5
|
-
import { assertUniqueMixedChildIdentifiers, assertUniqueStructuralChildIdentifiers, partitionChildren } from "./internal/children.js";
|
|
6
6
|
import { Function, Predicate } from "effect";
|
|
7
7
|
// src/Group.ts
|
|
8
8
|
var Group_exports = /* @__PURE__ */ __exportAll({
|
package/dist/Http.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Any } from "./AuthMethod.js";
|
|
2
1
|
import { ActionHandlerError, ActionHandlerFailure, HandlerContext, RetryableActionHandlerError } from "./Action.js";
|
|
2
|
+
import { Any } from "./AuthMethod.js";
|
|
3
3
|
import { File as File$1 } from "./Files.js";
|
|
4
4
|
import "./Http.js";
|
|
5
5
|
import { Effect, Record, Schema } from "effect";
|
package/dist/OAuthFlow.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { Service as Service$1 } from "./OAuth2TokenRefresher.js";
|
|
3
2
|
import { OAuth2ProviderTokenResponse } from "./AuthMethod.js";
|
|
3
|
+
import { Service as Service$1 } from "./OAuth2TokenRefresher.js";
|
|
4
4
|
import "./OAuthFlow.js";
|
|
5
5
|
import { Array, Clock, ConfigProvider, Context, Effect, HashSet, Layer, Predicate, Random, Record, Redacted, Schema, String, pipe } from "effect";
|
|
6
6
|
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
|
package/dist/Plugin.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Any as Any$1 } from "./
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Any as Any$3, RuntimeContract } from "./AgentChannel.js";
|
|
1
|
+
import { ActionHandlerFailure, Any as Any$1, HandlerContext, Input, Output as Output$1 } from "./Action.js";
|
|
2
|
+
import { Any as Any$2, RuntimeContract } from "./AgentChannel.js";
|
|
3
|
+
import { Any as Any$3 } from "./AuthMethod.js";
|
|
5
4
|
import { ConnectionResolutionContext } from "./ConnectionResolver.js";
|
|
6
|
-
import {
|
|
5
|
+
import { Any as Any$4 } from "./Group.js";
|
|
6
|
+
import { ContextForContract } from "./internal/auth-context.js";
|
|
7
7
|
import { FilterChildren } from "./internal/children.js";
|
|
8
|
-
import { Any as Any$5 } from "./Group.js";
|
|
9
8
|
import { ActionHandlerService, ActionHandlerServiceOf, HandlerServices as HandlerServices$1 } from "./internal/plugin-handlers.js";
|
|
9
|
+
import { ActivationResult, Any as Any$5, Config as Config$1, EmitResult, Output as Output$2, PollingInput, State, VerifyResult, WebhookActivationInput, WebhookLifecycleInput } from "./Trigger.js";
|
|
10
10
|
import { Effect, Layer, Option, Pipeable, Scope } from "effect";
|
|
11
11
|
import { HttpClientRequest } from "effect/http";
|
|
12
12
|
declare namespace Plugin_d_exports {
|
|
@@ -33,7 +33,7 @@ export type Category = (typeof categories)[number];
|
|
|
33
33
|
* @since 0.0.0
|
|
34
34
|
* @category models
|
|
35
35
|
*/
|
|
36
|
-
export interface SandboxAccess<Methods extends readonly Any$
|
|
36
|
+
export interface SandboxAccess<Methods extends readonly Any$3[] = readonly Any$3[]> {
|
|
37
37
|
/** Origins, such as `https://github.com`, that may receive the Connection's credential. */
|
|
38
38
|
origins(context: HandlerContext<Methods>): readonly string[];
|
|
39
39
|
/**
|
|
@@ -66,11 +66,11 @@ export interface Any extends Pipeable.Pipeable {
|
|
|
66
66
|
readonly categories: readonly Category[];
|
|
67
67
|
readonly homepageUrl: string | undefined;
|
|
68
68
|
readonly docsUrl: string | undefined;
|
|
69
|
-
readonly authMethods: readonly Any$
|
|
70
|
-
readonly groups: readonly Any$
|
|
71
|
-
readonly actions: readonly Any$
|
|
72
|
-
readonly triggers: readonly Any$
|
|
73
|
-
readonly agentChannels: readonly Any$
|
|
69
|
+
readonly authMethods: readonly Any$3[];
|
|
70
|
+
readonly groups: readonly Any$4[];
|
|
71
|
+
readonly actions: readonly Any$1[];
|
|
72
|
+
readonly triggers: readonly Any$5[];
|
|
73
|
+
readonly agentChannels: readonly Any$2[];
|
|
74
74
|
readonly sandboxAccess: SandboxAccess | undefined;
|
|
75
75
|
readonly layer: Layer.Layer<never, any, any>;
|
|
76
76
|
}
|
|
@@ -80,7 +80,7 @@ export interface Any extends Pipeable.Pipeable {
|
|
|
80
80
|
* @since 0.0.0
|
|
81
81
|
* @category models
|
|
82
82
|
*/
|
|
83
|
-
export interface Plugin<out Identifier extends string = string, out AuthMethods extends readonly Any$
|
|
83
|
+
export interface Plugin<out Identifier extends string = string, out AuthMethods extends readonly Any$3[] = readonly [], out Groups extends readonly Any$4[] = readonly [], out Actions extends readonly Any$1[] = readonly [], out Triggers extends readonly Any$5[] = readonly [], out Channels extends readonly Any$2[] = readonly [], LayerOutput = never, out LayerError = never, out LayerRequirements = never> extends Pipeable.Pipeable {
|
|
84
84
|
readonly [TypeId]: TypeId;
|
|
85
85
|
readonly identifier: Identifier;
|
|
86
86
|
readonly name: string | undefined;
|
|
@@ -104,7 +104,7 @@ export interface Plugin<out Identifier extends string = string, out AuthMethods
|
|
|
104
104
|
* @since 0.6.0
|
|
105
105
|
* @category models
|
|
106
106
|
*/
|
|
107
|
-
export type Definition<Identifier extends string, Methods extends readonly Any$
|
|
107
|
+
export type Definition<Identifier extends string, Methods extends readonly Any$3[] = readonly [], Groups extends readonly Any$4[] = readonly [], Actions extends readonly Any$1[] = readonly [], Triggers extends readonly Any$5[] = readonly [], Channels extends readonly Any$2[] = readonly []> = Plugin<Identifier, Methods, Groups, Actions, Triggers, Channels>;
|
|
108
108
|
/**
|
|
109
109
|
* A plugin contract with the services its Layer provides.
|
|
110
110
|
*
|
|
@@ -134,27 +134,27 @@ export type LayerError<Plugins extends readonly Any[]> = Plugins[number] extends
|
|
|
134
134
|
*/
|
|
135
135
|
export type LayerRequirements<Plugins extends readonly Any[]> = Plugins[number] extends Plugin<any, any, any, any, any, any, any, any, infer Requirements> ? Requirements : never;
|
|
136
136
|
/** @since 0.0.0 @category type-level */
|
|
137
|
-
export type StructuralChild = Any$
|
|
137
|
+
export type StructuralChild = Any$4 | Any$1 | Any$5;
|
|
138
138
|
/** @since 0.0.0 @category type-level */
|
|
139
|
-
export type GroupsFromChildren<Children extends readonly StructuralChild[]> = FilterChildren<Children, Any$
|
|
139
|
+
export type GroupsFromChildren<Children extends readonly StructuralChild[]> = FilterChildren<Children, Any$4>;
|
|
140
140
|
/** @since 0.0.0 @category type-level */
|
|
141
|
-
export type ActionsFromChildren<Children extends readonly StructuralChild[]> = FilterChildren<Children, Any$
|
|
141
|
+
export type ActionsFromChildren<Children extends readonly StructuralChild[]> = FilterChildren<Children, Any$1>;
|
|
142
142
|
/** @since 0.0.0 @category type-level */
|
|
143
|
-
export type TriggersFromChildren<Children extends readonly StructuralChild[]> = FilterChildren<Children, Any$
|
|
143
|
+
export type TriggersFromChildren<Children extends readonly StructuralChild[]> = FilterChildren<Children, Any$5>;
|
|
144
144
|
/**
|
|
145
145
|
* Result of appending capabilities to a plugin.
|
|
146
146
|
*
|
|
147
147
|
* @since 0.0.0
|
|
148
148
|
* @category type-level
|
|
149
149
|
*/
|
|
150
|
-
export type AddChildren<P extends Any, AddedGroups extends readonly Any$
|
|
150
|
+
export type AddChildren<P extends Any, AddedGroups extends readonly Any$4[] = readonly [], AddedActions extends readonly Any$1[] = readonly [], AddedTriggers extends readonly Any$5[] = readonly [], AddedChannels extends readonly Any$2[] = readonly []> = P extends Plugin<infer Identifier, infer Methods, infer Groups, infer Actions, infer Triggers, infer Channels, infer Output, infer Error, infer Requirements> ? Plugin<Identifier, Methods, readonly [...Groups, ...AddedGroups], readonly [...Actions, ...AddedActions], readonly [...Triggers, ...AddedTriggers], readonly [...Channels, ...AddedChannels], Output, Error, Requirements> : never;
|
|
151
151
|
/**
|
|
152
152
|
* Result of appending auth methods to a plugin.
|
|
153
153
|
*
|
|
154
154
|
* @since 0.0.0
|
|
155
155
|
* @category type-level
|
|
156
156
|
*/
|
|
157
|
-
export type AddAuthMethods<P extends Any, AddedMethods extends readonly Any$
|
|
157
|
+
export type AddAuthMethods<P extends Any, AddedMethods extends readonly Any$3[]> = P extends Plugin<infer Identifier, infer Methods, infer Groups, infer Actions, infer Triggers, infer Channels, infer Output, infer Error, infer Requirements> ? Plugin<Identifier, readonly [...Methods, ...AddedMethods], Groups, Actions, Triggers, Channels, Output, Error, Requirements> : never;
|
|
158
158
|
/**
|
|
159
159
|
* Create an empty {@link Plugin}.
|
|
160
160
|
*
|
|
@@ -210,7 +210,7 @@ export declare const withCategories: {
|
|
|
210
210
|
* @since 0.6.0
|
|
211
211
|
* @category combinators
|
|
212
212
|
*/
|
|
213
|
-
export declare const withAuthMethods: <const Methods extends readonly Any$
|
|
213
|
+
export declare const withAuthMethods: <const Methods extends readonly Any$3[]>(methods: Methods) => <P extends Any>(plugin: P) => AddAuthMethods<P, Methods>;
|
|
214
214
|
/**
|
|
215
215
|
* Add an authentication alternative. Actions and triggers accept every method.
|
|
216
216
|
*
|
|
@@ -218,8 +218,8 @@ export declare const withAuthMethods: <const Methods extends readonly Any$1[]>(m
|
|
|
218
218
|
* @category combinators
|
|
219
219
|
*/
|
|
220
220
|
export declare const withAuthMethod: {
|
|
221
|
-
<const Method extends Any$
|
|
222
|
-
<P extends Any, const Method extends Any$
|
|
221
|
+
<const Method extends Any$3>(method: Method): <P extends Any>(plugin: P) => AddAuthMethods<P, readonly [Method]>;
|
|
222
|
+
<P extends Any, const Method extends Any$3>(plugin: P, method: Method): AddAuthMethods<P, readonly [Method]>;
|
|
223
223
|
};
|
|
224
224
|
/**
|
|
225
225
|
* Lets commands in a run sandbox use the plugin's Connection through Dual's sandbox gateway.
|
|
@@ -227,32 +227,32 @@ export declare const withAuthMethod: {
|
|
|
227
227
|
* @since 0.6.0
|
|
228
228
|
* @category combinators
|
|
229
229
|
*/
|
|
230
|
-
export declare const withSandboxAccess: <Methods extends readonly Any$
|
|
230
|
+
export declare const withSandboxAccess: <Methods extends readonly Any$3[]>(access: SandboxAccess<Methods>) => <P extends Any>(plugin: P & {
|
|
231
231
|
readonly authMethods: Methods;
|
|
232
232
|
}) => P;
|
|
233
233
|
/** @since 0.6.0 @category combinators */
|
|
234
234
|
export declare const withAction: {
|
|
235
|
-
<const Added extends Any$
|
|
236
|
-
<P extends Any, const Added extends Any$
|
|
235
|
+
<const Added extends Any$1>(action: Added): <P extends Any>(plugin: P) => AddChildren<P, readonly [], readonly [Added]>;
|
|
236
|
+
<P extends Any, const Added extends Any$1>(plugin: P, action: Added): AddChildren<P, readonly [], readonly [Added]>;
|
|
237
237
|
};
|
|
238
238
|
/** @since 0.6.0 @category combinators */
|
|
239
239
|
export declare const withGroup: {
|
|
240
|
-
<const Added extends Any$
|
|
241
|
-
<P extends Any, const Added extends Any$
|
|
240
|
+
<const Added extends Any$4>(group: Added): <P extends Any>(plugin: P) => AddChildren<P, readonly [Added]>;
|
|
241
|
+
<P extends Any, const Added extends Any$4>(plugin: P, group: Added): AddChildren<P, readonly [Added]>;
|
|
242
242
|
};
|
|
243
243
|
/** @since 0.6.0 @category combinators */
|
|
244
244
|
export declare const withTrigger: {
|
|
245
|
-
<const Added extends Any$
|
|
246
|
-
<P extends Any, const Added extends Any$
|
|
245
|
+
<const Added extends Any$5>(trigger: Added): <P extends Any>(plugin: P) => AddChildren<P, readonly [], readonly [], readonly [Added]>;
|
|
246
|
+
<P extends Any, const Added extends Any$5>(plugin: P, trigger: Added): AddChildren<P, readonly [], readonly [], readonly [Added]>;
|
|
247
247
|
};
|
|
248
248
|
/** Add the generated action groups. @since 0.6.0 @category combinators */
|
|
249
|
-
export declare const withGroups: <const Groups extends readonly Any$
|
|
249
|
+
export declare const withGroups: <const Groups extends readonly Any$4[]>(groups: Groups) => <P extends Any>(plugin: P) => AddChildren<P, Groups>;
|
|
250
250
|
/** Add trigger definitions from an overlay. @since 0.6.0 @category combinators */
|
|
251
|
-
export declare const withTriggers: <const Triggers extends readonly Any$
|
|
251
|
+
export declare const withTriggers: <const Triggers extends readonly Any$5[]>(triggers: Triggers) => <P extends Any>(plugin: P) => AddChildren<P, readonly [], readonly [], Triggers>;
|
|
252
252
|
/** Add grouped capabilities. @since 0.6.0 @category combinators */
|
|
253
253
|
export declare const add: <const Children extends readonly StructuralChild[]>(...children: Children) => <P extends Any>(plugin: P) => AddChildren<P, GroupsFromChildren<Children>, ActionsFromChildren<Children>, TriggersFromChildren<Children>>;
|
|
254
254
|
/** Add an Agent Channel; its definition owns its exact auth subset. @since 0.6.0 @category combinators */
|
|
255
|
-
export declare const withAgentChannel: <const Channel extends Any$
|
|
255
|
+
export declare const withAgentChannel: <const Channel extends Any$2>(channel: Channel) => <P extends Any>(plugin: P) => AddChildren<P, readonly [], readonly [], readonly [], readonly [Channel]>;
|
|
256
256
|
/**
|
|
257
257
|
* Attach runtime services to a plugin definition.
|
|
258
258
|
*
|
|
@@ -266,10 +266,10 @@ export declare const provide: {
|
|
|
266
266
|
/** Runtime handler services contributed by a plugin. @since 0.6.0 @category type-level */
|
|
267
267
|
export type HandlerServices<P extends Any> = HandlerServices$1<P>;
|
|
268
268
|
interface Node {
|
|
269
|
-
readonly actions: readonly Any$
|
|
270
|
-
readonly groups: readonly Any$
|
|
271
|
-
readonly triggers: readonly Any$
|
|
272
|
-
readonly agentChannels?: readonly Any$
|
|
269
|
+
readonly actions: readonly Any$1[];
|
|
270
|
+
readonly groups: readonly Any$4[];
|
|
271
|
+
readonly triggers: readonly Any$5[];
|
|
272
|
+
readonly agentChannels?: readonly Any$2[];
|
|
273
273
|
}
|
|
274
274
|
type ActionName<N extends Node> = N["actions"][number]["identifier"];
|
|
275
275
|
type GroupName<N extends Node> = N["groups"][number]["identifier"];
|
|
@@ -284,20 +284,20 @@ type TriggerNamed<N extends Node, Name> = Extract<N["triggers"][number], {
|
|
|
284
284
|
readonly identifier: Name;
|
|
285
285
|
}>;
|
|
286
286
|
type Channels<N extends Node> = N extends {
|
|
287
|
-
readonly agentChannels: infer C extends readonly Any$
|
|
287
|
+
readonly agentChannels: infer C extends readonly Any$2[];
|
|
288
288
|
} ? C[number] : never;
|
|
289
289
|
type ChannelName<N extends Node> = Channels<N>["identifier"];
|
|
290
290
|
type ChannelNamed<N extends Node, Name> = Extract<Channels<N>, {
|
|
291
291
|
readonly identifier: Name;
|
|
292
292
|
}>;
|
|
293
293
|
type Names<N extends Node> = ActionName<N> | GroupName<N> | TriggerName<N> | ChannelName<N>;
|
|
294
|
-
type ActionHandler<A extends Any$
|
|
295
|
-
type TriggerContext<T extends Any$
|
|
296
|
-
type Emit<T extends Any$
|
|
297
|
-
type WebhookInput<T extends Any$
|
|
298
|
-
type ActivationInput<T extends Any$
|
|
294
|
+
type ActionHandler<A extends Any$1, Methods extends readonly Any$3[], R> = (input: Input<A>, context: ContextForContract<Methods, A["requireAuth"]>) => Effect.Effect<Output$1<A>, ActionHandlerFailure, R>;
|
|
295
|
+
type TriggerContext<T extends Any$5, Methods extends readonly Any$3[]> = ContextForContract<Methods, T["requireAuth"]> & ConnectionResolutionContext;
|
|
296
|
+
type Emit<T extends Any$5> = EmitResult<Output$2<T>, State<T>>;
|
|
297
|
+
type WebhookInput<T extends Any$5> = WebhookLifecycleInput<Config$1<T>, State<T>>;
|
|
298
|
+
type ActivationInput<T extends Any$5> = WebhookActivationInput<Config$1<T>, State<T>>;
|
|
299
299
|
/** Lifecycle handlers each trigger kind must implement; each hook infers its own requirements. */
|
|
300
|
-
type TriggerLifecycle<T extends Any$
|
|
300
|
+
type TriggerLifecycle<T extends Any$5, Methods extends readonly Any$3[], RActivate, RDeactivate, RVerify, REmit> = T["kind"] extends "webhook" ? {
|
|
301
301
|
readonly activate?: (input: ActivationInput<T>, context: TriggerContext<T, Methods>) => Effect.Effect<ActivationResult<State<T>>, unknown, RActivate>;
|
|
302
302
|
readonly deactivate?: (input: ActivationInput<T>, context: TriggerContext<T, Methods>) => Effect.Effect<void, unknown, RDeactivate>;
|
|
303
303
|
readonly verify?: (input: WebhookInput<T>, context: TriggerContext<T, Methods>) => Effect.Effect<void | VerifyResult<State<T>>, unknown, RVerify>;
|
|
@@ -307,7 +307,7 @@ type TriggerLifecycle<T extends Any$4, Methods extends readonly Any$1[], RActiva
|
|
|
307
307
|
};
|
|
308
308
|
type UnionToIntersection<U> = (U extends unknown ? (value: U) => void : never) extends ((value: infer I) => void) ? I : never;
|
|
309
309
|
/** Typed lifecycles exported by a trigger overlay. @since 0.6.0 @category handlers */
|
|
310
|
-
export type TriggerHandlers<Triggers extends readonly Any$
|
|
310
|
+
export type TriggerHandlers<Triggers extends readonly Any$5[], Methods extends readonly Any$3[]> = { readonly [T in Triggers[number] as T["identifier"]]: TriggerLifecycle<T, Methods, any, any, any, any>; };
|
|
311
311
|
type LifecycleRequirements<H> = H extends ((...args: any[]) => Effect.Effect<any, any, infer R>) ? R : H extends object ? { [K in keyof H]: LifecycleRequirements<H[K]>; }[keyof H] : never;
|
|
312
312
|
/** Rejects a union of names, which would mark several capabilities handled by one handler. */
|
|
313
313
|
type Single<Name> = [Name] extends [UnionToIntersection<Name>] ? unknown : never;
|
|
@@ -318,7 +318,7 @@ type Single<Name> = [Name] extends [UnionToIntersection<Name>] ? unknown : never
|
|
|
318
318
|
* @since 0.6.0
|
|
319
319
|
* @category handlers
|
|
320
320
|
*/
|
|
321
|
-
export interface HandlerCollection<N extends Node, Methods extends readonly Any$
|
|
321
|
+
export interface HandlerCollection<N extends Node, Methods extends readonly Any$3[], Handled extends PropertyKey = never, R = never> {
|
|
322
322
|
readonly "~node": N;
|
|
323
323
|
readonly "~handled": Handled;
|
|
324
324
|
readonly "~requirements": R;
|
package/dist/Plugin.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { validateIdentifier } from "./internal/identifier.js";
|
|
3
|
-
import { PipeableProto } from "./internal/proto.js";
|
|
4
2
|
import { ChannelError, validateDefinition } from "./AgentChannel.js";
|
|
5
3
|
import { assertNoDuplicateAuthMethodIdentifiers } from "./internal/auth-runtime.js";
|
|
6
|
-
import { appendElements } from "./internal/collection-utils.js";
|
|
7
4
|
import { assertUniqueMixedChildIdentifiers, assertUniqueStructuralChildIdentifiers, partitionChildren } from "./internal/children.js";
|
|
5
|
+
import { appendElements } from "./internal/collection-utils.js";
|
|
6
|
+
import { validateIdentifier } from "./internal/identifier.js";
|
|
8
7
|
import { toHandlers } from "./internal/plugin-handlers.js";
|
|
8
|
+
import { PipeableProto } from "./internal/proto.js";
|
|
9
9
|
import { Array, Effect, Function, Layer, Option, Predicate, Result, String } from "effect";
|
|
10
10
|
import { Url, UrlParams } from "effect/http";
|
|
11
11
|
// src/Plugin.ts
|