@dual-os/sdk 0.0.0-stage → 0.8.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -0
- package/README.md +19 -2
- package/dist/Action.d.ts +201 -0
- package/dist/Action.d.ts.map +1 -0
- package/dist/Action.js +172 -0
- package/dist/Action.js.map +1 -0
- package/dist/AgentChannel.d.ts +1717 -0
- package/dist/AgentChannel.d.ts.map +1 -0
- package/dist/AgentChannel.js +708 -0
- package/dist/AgentChannel.js.map +1 -0
- package/dist/AgentChannelConformance.d.ts +1543 -0
- package/dist/AgentChannelConformance.d.ts.map +1 -0
- package/dist/AgentChannelConformance.js +163 -0
- package/dist/AgentChannelConformance.js.map +1 -0
- package/dist/AgentChannelRuntime.d.ts +78 -0
- package/dist/AgentChannelRuntime.d.ts.map +1 -0
- package/dist/AgentChannelRuntime.js +270 -0
- package/dist/AgentChannelRuntime.js.map +1 -0
- package/dist/AiProvider.d.ts +132 -0
- package/dist/AiProvider.d.ts.map +1 -0
- package/dist/AiProvider.js +100 -0
- package/dist/AiProvider.js.map +1 -0
- package/dist/AuthMethod.d.ts +381 -0
- package/dist/AuthMethod.d.ts.map +1 -0
- package/dist/AuthMethod.js +225 -0
- package/dist/AuthMethod.js.map +1 -0
- package/dist/AuthMethodBinding.d.ts +77 -0
- package/dist/AuthMethodBinding.d.ts.map +1 -0
- package/dist/AuthMethodBinding.js +31 -0
- package/dist/AuthMethodBinding.js.map +1 -0
- package/dist/AuthMethodExecution.d.ts +223 -0
- package/dist/AuthMethodExecution.d.ts.map +1 -0
- package/dist/AuthMethodExecution.js +277 -0
- package/dist/AuthMethodExecution.js.map +1 -0
- package/dist/ConnectionResolver.d.ts +219 -0
- package/dist/ConnectionResolver.d.ts.map +1 -0
- package/dist/ConnectionResolver.js +153 -0
- package/dist/ConnectionResolver.js.map +1 -0
- package/dist/DefinitionError.d.ts +67 -0
- package/dist/DefinitionError.d.ts.map +1 -0
- package/dist/DefinitionError.js +82 -0
- package/dist/DefinitionError.js.map +1 -0
- package/dist/DualRegistry.d.ts +71 -0
- package/dist/DualRegistry.d.ts.map +1 -0
- package/dist/DualRegistry.js +96 -0
- package/dist/DualRegistry.js.map +1 -0
- package/dist/DualRuntime.d.ts +279 -0
- package/dist/DualRuntime.d.ts.map +1 -0
- package/dist/DualRuntime.js +311 -0
- package/dist/DualRuntime.js.map +1 -0
- package/dist/Files.d.ts +80 -0
- package/dist/Files.d.ts.map +1 -0
- package/dist/Files.js +66 -0
- package/dist/Files.js.map +1 -0
- package/dist/Group.d.ts +106 -0
- package/dist/Group.d.ts.map +1 -0
- package/dist/Group.js +86 -0
- package/dist/Group.js.map +1 -0
- package/dist/Http.d.ts +342 -0
- package/dist/Http.d.ts.map +1 -0
- package/dist/Http.js +677 -0
- package/dist/Http.js.map +1 -0
- package/dist/Mcp.d.ts +109 -0
- package/dist/Mcp.d.ts.map +1 -0
- package/dist/Mcp.js +176 -0
- package/dist/Mcp.js.map +1 -0
- package/dist/OAuth2TokenRefresher.d.ts +18 -0
- package/dist/OAuth2TokenRefresher.d.ts.map +1 -0
- package/dist/OAuth2TokenRefresher.js +19 -0
- package/dist/OAuth2TokenRefresher.js.map +1 -0
- package/dist/OAuthFlow.d.ts +71 -0
- package/dist/OAuthFlow.d.ts.map +1 -0
- package/dist/OAuthFlow.js +488 -0
- package/dist/OAuthFlow.js.map +1 -0
- package/dist/Plugin.d.ts +383 -0
- package/dist/Plugin.d.ts.map +1 -0
- package/dist/Plugin.js +249 -0
- package/dist/Plugin.js.map +1 -0
- package/dist/PluginRuntime.d.ts +3186 -0
- package/dist/PluginRuntime.d.ts.map +1 -0
- package/dist/PluginRuntime.js +331 -0
- package/dist/PluginRuntime.js.map +1 -0
- package/dist/Runner.d.ts +1 -0
- package/dist/Runner.js +124 -0
- package/dist/Runner.js.map +1 -0
- package/dist/ToolFile.d.ts +23 -0
- package/dist/ToolFile.d.ts.map +1 -0
- package/dist/ToolFile.js +33 -0
- package/dist/ToolFile.js.map +1 -0
- package/dist/Trigger.d.ts +358 -0
- package/dist/Trigger.d.ts.map +1 -0
- package/dist/Trigger.js +287 -0
- package/dist/Trigger.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +24 -0
- package/dist/internal/auth-context.d.ts +23 -0
- package/dist/internal/auth-context.d.ts.map +1 -0
- package/dist/internal/auth-context.js +1 -0
- package/dist/internal/auth-execution.d.ts +27 -0
- package/dist/internal/auth-execution.d.ts.map +1 -0
- package/dist/internal/auth-execution.js +66 -0
- package/dist/internal/auth-execution.js.map +1 -0
- package/dist/internal/auth-runtime.d.ts +5 -0
- package/dist/internal/auth-runtime.d.ts.map +1 -0
- package/dist/internal/auth-runtime.js +16 -0
- package/dist/internal/auth-runtime.js.map +1 -0
- package/dist/internal/capabilities.d.ts +24 -0
- package/dist/internal/capabilities.d.ts.map +1 -0
- package/dist/internal/capabilities.js +22 -0
- package/dist/internal/capabilities.js.map +1 -0
- package/dist/internal/children.d.ts +34 -0
- package/dist/internal/children.d.ts.map +1 -0
- package/dist/internal/children.js +53 -0
- package/dist/internal/children.js.map +1 -0
- package/dist/internal/collection-utils.d.ts +4 -0
- package/dist/internal/collection-utils.d.ts.map +1 -0
- package/dist/internal/collection-utils.js +6 -0
- package/dist/internal/collection-utils.js.map +1 -0
- package/dist/internal/dual/actions.d.ts +33 -0
- package/dist/internal/dual/actions.d.ts.map +1 -0
- package/dist/internal/dual/actions.js +26 -0
- package/dist/internal/dual/actions.js.map +1 -0
- package/dist/internal/dual/invoke.d.ts +63 -0
- package/dist/internal/dual/invoke.d.ts.map +1 -0
- package/dist/internal/dual/invoke.js +75 -0
- package/dist/internal/dual/invoke.js.map +1 -0
- package/dist/internal/dual/registry.d.ts +125 -0
- package/dist/internal/dual/registry.d.ts.map +1 -0
- package/dist/internal/dual/registry.js +172 -0
- package/dist/internal/dual/registry.js.map +1 -0
- package/dist/internal/dual/triggers.d.ts +29 -0
- package/dist/internal/dual/triggers.d.ts.map +1 -0
- package/dist/internal/dual/triggers.js +26 -0
- package/dist/internal/dual/triggers.js.map +1 -0
- package/dist/internal/handler-context.d.ts +9 -0
- package/dist/internal/handler-context.d.ts.map +1 -0
- package/dist/internal/handler-context.js +31 -0
- package/dist/internal/handler-context.js.map +1 -0
- package/dist/internal/identifier.d.ts +6 -0
- package/dist/internal/identifier.d.ts.map +1 -0
- package/dist/internal/identifier.js +28 -0
- package/dist/internal/identifier.js.map +1 -0
- package/dist/internal/plugin-handlers.d.ts +38 -0
- package/dist/internal/plugin-handlers.d.ts.map +1 -0
- package/dist/internal/plugin-handlers.js +52 -0
- package/dist/internal/plugin-handlers.js.map +1 -0
- package/dist/internal/proto.d.ts +7 -0
- package/dist/internal/proto.d.ts.map +1 -0
- package/dist/internal/proto.js +10 -0
- package/dist/internal/proto.js.map +1 -0
- package/dist/internal/schema-runtime.d.ts +6 -0
- package/dist/internal/schema-runtime.d.ts.map +1 -0
- package/dist/internal/schema-runtime.js +10 -0
- package/dist/internal/schema-runtime.js.map +1 -0
- package/dist/internal/trigger-runtime-shared.d.ts +41 -0
- package/dist/internal/trigger-runtime-shared.d.ts.map +1 -0
- package/dist/internal/trigger-runtime-shared.js +132 -0
- package/dist/internal/trigger-runtime-shared.js.map +1 -0
- package/dist/internal/trigger-runtime.d.ts +12 -0
- package/dist/internal/trigger-runtime.d.ts.map +1 -0
- package/dist/internal/trigger-runtime.js +95 -0
- package/dist/internal/trigger-runtime.js.map +1 -0
- package/dist/internal/types.d.ts +7 -0
- package/dist/internal/types.d.ts.map +1 -0
- package/dist/internal/types.js +1 -0
- package/dist/remote-runtime.d.ts +585 -0
- package/dist/remote-runtime.d.ts.map +1 -0
- package/dist/remote-runtime.js +367 -0
- package/dist/remote-runtime.js.map +1 -0
- package/package.json +55 -4
- package/src/Action.ts +370 -0
- package/src/AgentChannel.ts +860 -0
- package/src/AgentChannelConformance.ts +124 -0
- package/src/AgentChannelRuntime.ts +616 -0
- package/src/AiProvider.ts +255 -0
- package/src/AuthMethod.ts +954 -0
- package/src/AuthMethodBinding.ts +112 -0
- package/src/AuthMethodExecution.ts +542 -0
- package/src/ConnectionResolver.ts +265 -0
- package/src/DefinitionError.ts +115 -0
- package/src/DualRegistry.ts +152 -0
- package/src/DualRuntime.ts +1081 -0
- package/src/Files.ts +89 -0
- package/src/Group.ts +292 -0
- package/src/Http.ts +1205 -0
- package/src/Mcp.ts +299 -0
- package/src/OAuth2TokenRefresher.ts +22 -0
- package/src/OAuthFlow.ts +874 -0
- package/src/Plugin.ts +912 -0
- package/src/PluginRuntime.ts +414 -0
- package/src/Runner.ts +248 -0
- package/src/ToolFile.ts +28 -0
- package/src/Trigger.ts +722 -0
- package/src/index.ts +158 -0
- package/src/internal/auth-context.ts +27 -0
- package/src/internal/auth-execution.ts +241 -0
- package/src/internal/auth-runtime.ts +20 -0
- package/src/internal/capabilities.ts +55 -0
- package/src/internal/children.ts +126 -0
- package/src/internal/collection-utils.ts +8 -0
- package/src/internal/dual/actions.ts +116 -0
- package/src/internal/dual/invoke.ts +307 -0
- package/src/internal/dual/registry.ts +340 -0
- package/src/internal/dual/triggers.ts +128 -0
- package/src/internal/handler-context.ts +57 -0
- package/src/internal/identifier.ts +27 -0
- package/src/internal/plugin-handlers.ts +146 -0
- package/src/internal/proto.ts +8 -0
- package/src/internal/schema-runtime.ts +15 -0
- package/src/internal/trigger-runtime-shared.ts +449 -0
- package/src/internal/trigger-runtime.ts +223 -0
- package/src/internal/types.ts +12 -0
- package/src/remote-runtime.ts +469 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","names":[],"sources":["../../../src/internal/dual/actions.ts"],"sourcesContent":["import type * as Action from \"../../Action.ts\";\nimport type * as AuthMethod from \"../../AuthMethod.ts\";\nimport type { PluginInstallation } from \"../../DualRuntime.ts\";\nimport type * as Group from \"../../Group.ts\";\nimport type * as Plugin from \"../../Plugin.ts\";\nimport { walkCapabilities } from \"../capabilities.ts\";\nimport type { MachineIdSeparator } from \"../identifier.ts\";\nimport type { IsAny, IsGenericArray } from \"../types.ts\";\n\ninterface ActionEntry<Id extends string = string, ActionDef extends Action.Any = Action.Any> {\n readonly actionId: Id;\n readonly action: ActionDef;\n}\n\ntype ActionEntriesFromActions<Actions extends readonly Action.Any[], Prefix extends string> =\n IsGenericArray<Actions> extends true\n ? ActionEntry\n : Actions[number] extends infer ActionDef\n ? ActionDef extends Action.Any\n ? ActionEntry<`${Prefix}${typeof MachineIdSeparator}${ActionDef[\"identifier\"]}`, ActionDef>\n : never\n : never;\n\ntype ActionEntriesFromGroups<Groups extends readonly Group.Any[], Prefix extends string> =\n IsGenericArray<Groups> extends true\n ? ActionEntry\n : Groups[number] extends infer GroupDef\n ? GroupDef extends Group.Any\n ? GroupActionEntries<\n GroupDef,\n `${Prefix}${typeof MachineIdSeparator}${GroupDef[\"identifier\"]}`\n >\n : never\n : never;\n\ntype GroupActionEntries<GroupDef extends Group.Any, Prefix extends string> =\n | ActionEntriesFromActions<GroupDef[\"actions\"], Prefix>\n | ActionEntriesFromGroups<GroupDef[\"groups\"], Prefix>;\n\nexport type PluginActionEntries<P extends Plugin.Any> =\n | ActionEntriesFromActions<P[\"actions\"], P[\"identifier\"]>\n | ActionEntriesFromGroups<P[\"groups\"], P[\"identifier\"]>;\n\nexport type AllActionEntries<Plugins extends readonly Plugin.Any[]> =\n IsAny<Plugins> extends true\n ? ActionEntry\n : IsGenericArray<Plugins> extends true\n ? ActionEntry\n : Plugins[number] extends infer P\n ? P extends Plugin.Any\n ? PluginActionEntries<P>\n : never\n : never;\n\ntype GroupActions<Groups extends readonly Group.Any[]> =\n IsGenericArray<Groups> extends true\n ? Action.Any\n : Groups[number] extends infer GroupDef\n ? GroupDef extends Group.Any\n ? GroupDef[\"actions\"][number] | GroupActions<GroupDef[\"groups\"]>\n : never\n : never;\n\nexport type PluginActions<P extends Plugin.Any> = P[\"actions\"][number] | GroupActions<P[\"groups\"]>;\n\nexport interface RuntimeActionEntry<\n out ActionId extends string = string,\n out ProviderId extends string = string,\n out ActionDef extends Action.Any = Action.Any,\n out AllowedMethods extends readonly AuthMethod.Any[] = readonly AuthMethod.Any[],\n> {\n readonly actionId: ActionId;\n readonly providerId: ProviderId;\n readonly localId: string;\n readonly pluginVersion: string;\n readonly action: ActionDef;\n readonly authMethods: AllowedMethods;\n}\n\nconst entriesOf = (installation: PluginInstallation): readonly RuntimeActionEntry[] =>\n walkCapabilities(installation.plugin, owner => owner.actions).map(\n ({ localId, canonicalId, node }) => ({\n action: node,\n actionId: canonicalId,\n authMethods: installation.plugin.authMethods,\n localId,\n pluginVersion: installation.version,\n providerId: installation.plugin.identifier,\n }),\n );\n\nexport const collectActionEntries = (\n installations: readonly PluginInstallation[],\n): readonly RuntimeActionEntry[] => installations.flatMap(entriesOf);\n\nconst actionIndex = new WeakMap<\n readonly PluginInstallation[],\n ReadonlyMap<string, RuntimeActionEntry>\n>();\n\n/** An action of the installed releases, or of the exact `version` when the caller pins one. */\nexport const resolveAction = (\n installations: readonly PluginInstallation[],\n actionId: string,\n version?: string,\n): RuntimeActionEntry | undefined => {\n let index = actionIndex.get(installations);\n if (index === undefined) {\n index = new Map(collectActionEntries(installations).map(entry => [entry.actionId, entry]));\n actionIndex.set(installations, index);\n }\n const entry = index.get(actionId);\n return entry === undefined || (version !== undefined && entry.pluginVersion !== version)\n ? undefined\n : entry;\n};\n"],"mappings":";;AA+EA,MAAM,aAAa,iBACjB,iBAAiB,aAAa,SAAQ,UAAS,MAAM,OAAO,CAAC,CAAC,KAC3D,EAAE,SAAS,aAAa,YAAY;CACnC,QAAQ;CACR,UAAU;CACV,aAAa,aAAa,OAAO;CACjC;CACA,eAAe,aAAa;CAC5B,YAAY,aAAa,OAAO;AAClC,EACF;AAEF,MAAa,wBACX,kBACkC,cAAc,QAAQ,SAAS;AAEnE,MAAM,8BAAc,IAAI,QAGtB;;AAGF,MAAa,iBACX,eACA,UACA,YACmC;CACnC,IAAI,QAAQ,YAAY,IAAI,aAAa;CACzC,IAAI,UAAU,KAAA,GAAW;EACvB,QAAQ,IAAI,IAAI,qBAAqB,aAAa,CAAC,CAAC,KAAI,UAAS,CAAC,MAAM,UAAU,KAAK,CAAC,CAAC;EACzF,YAAY,IAAI,eAAe,KAAK;CACtC;CACA,MAAM,QAAQ,MAAM,IAAI,QAAQ;CAChC,OAAO,UAAU,KAAA,KAAc,YAAY,KAAA,KAAa,MAAM,kBAAkB,UAC5E,KAAA,IACA;AACN"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Any } from "../../AuthMethod.js";
|
|
2
|
+
import { Action, ActionHandlerFailure, Any as Any$1, Handler, InputSchema, OutputSchema } from "../../Action.js";
|
|
3
|
+
import { ConnectionError, ConnectionResolutionContext, Service } from "../../ConnectionResolver.js";
|
|
4
|
+
import { AuthResolutionRequirements, AuthSchemaRequirements } from "../auth-execution.js";
|
|
5
|
+
import { ActionHandlerServiceOf } from "../plugin-handlers.js";
|
|
6
|
+
import { Any as Any$2 } from "../../Plugin.js";
|
|
7
|
+
import { PluginActionEntries } from "./actions.js";
|
|
8
|
+
import { Effect, Schema } from "effect";
|
|
9
|
+
//#region src/internal/dual/invoke.d.ts
|
|
10
|
+
export interface InvokeRequest {
|
|
11
|
+
readonly actionId: string;
|
|
12
|
+
/** The exact plugin release the caller pinned; another installed release does not run. */
|
|
13
|
+
readonly actionVersion?: string;
|
|
14
|
+
readonly pluginKey?: string;
|
|
15
|
+
readonly input: unknown;
|
|
16
|
+
readonly connectionId?: string;
|
|
17
|
+
readonly context?: ConnectionResolutionContext;
|
|
18
|
+
}
|
|
19
|
+
export interface InvokeMeta<ActionId extends string = string> {
|
|
20
|
+
readonly actionId: ActionId;
|
|
21
|
+
readonly providerId: string;
|
|
22
|
+
readonly pluginVersion: string;
|
|
23
|
+
}
|
|
24
|
+
export interface InvokeSuccess<ActionId extends string = string, Data = unknown> {
|
|
25
|
+
readonly data: Data;
|
|
26
|
+
readonly meta: InvokeMeta<ActionId>;
|
|
27
|
+
}
|
|
28
|
+
declare const FieldIssue_base: Schema.Class<FieldIssue, Schema.Struct<{
|
|
29
|
+
readonly message: Schema.String;
|
|
30
|
+
readonly path: Schema.String;
|
|
31
|
+
}>, {}>;
|
|
32
|
+
export declare class FieldIssue extends FieldIssue_base {}
|
|
33
|
+
declare const ActionNotFoundError_base: Schema.Class<ActionNotFoundError, Schema.TaggedStruct<"ActionNotFoundError", {
|
|
34
|
+
readonly actionId: Schema.String;
|
|
35
|
+
}>, import("effect/Cause").YieldableError>;
|
|
36
|
+
export declare class ActionNotFoundError extends ActionNotFoundError_base {}
|
|
37
|
+
declare const InvalidActionInputError_base: Schema.Class<InvalidActionInputError, Schema.TaggedStruct<"InvalidActionInputError", {
|
|
38
|
+
readonly actionId: Schema.String;
|
|
39
|
+
readonly description: Schema.String;
|
|
40
|
+
readonly fields: Schema.$Array<typeof FieldIssue>;
|
|
41
|
+
}>, import("effect/Cause").YieldableError>;
|
|
42
|
+
export declare class InvalidActionInputError extends InvalidActionInputError_base {}
|
|
43
|
+
declare const ActionHandlerNotFoundError_base: Schema.Class<ActionHandlerNotFoundError, Schema.TaggedStruct<"ActionHandlerNotFoundError", {
|
|
44
|
+
readonly actionId: Schema.String;
|
|
45
|
+
}>, import("effect/Cause").YieldableError>;
|
|
46
|
+
export declare class ActionHandlerNotFoundError extends ActionHandlerNotFoundError_base {}
|
|
47
|
+
declare const InvalidActionOutputError_base: Schema.Class<InvalidActionOutputError, Schema.TaggedStruct<"InvalidActionOutputError", {
|
|
48
|
+
readonly actionId: Schema.String;
|
|
49
|
+
readonly description: Schema.String;
|
|
50
|
+
readonly fields: Schema.$Array<typeof FieldIssue>;
|
|
51
|
+
}>, import("effect/Cause").YieldableError>;
|
|
52
|
+
export declare class InvalidActionOutputError extends InvalidActionOutputError_base {}
|
|
53
|
+
type InvokeResolvedActionError = InvalidActionInputError | InvalidActionOutputError | ActionHandlerNotFoundError | ActionHandlerFailure | ConnectionError;
|
|
54
|
+
export type InvokeError = ActionNotFoundError | InvokeResolvedActionError;
|
|
55
|
+
export type InvokeRequirementsFor<Plugins extends readonly Any$2[], ActionId extends string> = Plugins[number] extends (infer P) ? P extends Any$2 ? PluginRequirements<P, Extract<PluginActionEntries<P>, {
|
|
56
|
+
readonly actionId: ActionId;
|
|
57
|
+
}>["action"]> : never : never;
|
|
58
|
+
export type PluginRequirements<P extends Any$2, ActionDef extends Any$1> = [ActionDef] extends [never] ? never : ActionHandlerServiceOf<P> | InputSchema<ActionDef>["DecodingServices"] | OutputSchema<ActionDef>["EncodingServices"] | ([P["authMethods"][number]] extends [never] ? never : Service | AuthSchemaRequirements<P["authMethods"]> | AuthResolutionRequirements<P["authMethods"]>);
|
|
59
|
+
export declare const invokeResolvedAction: <ActionId extends string, Input extends Schema.Top, Output extends Schema.Top, ActionAuthMethods extends readonly Any[]>(providerId: string, actionId: ActionId, pluginVersion: string, action: Action<string, Input, Output>, authMethods: ActionAuthMethods, request: InvokeRequest) => Effect.Effect<InvokeSuccess<ActionId, Output["Type"]>, InvokeResolvedActionError, Handler<ActionId> | Input["DecodingServices"] | Output["EncodingServices"] | ([ActionAuthMethods[number]] extends [never] ? never : Service | AuthResolutionRequirements<ActionAuthMethods> | AuthSchemaRequirements<ActionAuthMethods>)>;
|
|
60
|
+
export declare const invokeResolvedActionJson: <ActionId extends string, Input extends Schema.Top, Output extends Schema.Top, ActionAuthMethods extends readonly Any[]>(providerId: string, actionId: ActionId, pluginVersion: string, action: Action<string, Input, Output>, authMethods: ActionAuthMethods, request: InvokeRequest) => Effect.Effect<InvokeSuccess<ActionId, Schema.Json>, InvokeResolvedActionError, Handler<ActionId> | Input["DecodingServices"] | Output["EncodingServices"] | ([ActionAuthMethods[number]] extends [never] ? never : Service | AuthResolutionRequirements<ActionAuthMethods> | AuthSchemaRequirements<ActionAuthMethods>)>;
|
|
61
|
+
//#endregion
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=invoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke.d.ts","names":["Action.ActionHandlerFailure","Plugin.Any","Action.Any","Action.InputSchema","Action.OutputSchema","ConnectionResolverService","AuthMethod.Any","Action.Action","Action.Handler"],"sources":["../../../src/internal/dual/invoke.ts"],"mappings":";;;;;;;;;iBAyBiB;WACN;;WAEA;WACA;WACA;WACA;WACA,UAAU;;iBAGJ,WAAW;WACjB,UAAU;WACV;WACA;;iBAGM,cAAc,kCAAkC;WACtD,MAAM;WACN,MAAM,WAAW;;;;;;qBAGf,mBAAmB;;;;qBAKnB,4BAA4B;;;;;;qBAK5B,gCAAgC;;;;qBAKhC,mCAAmC;;;;;;qBAKnC,iCAAiC;KAKzC,4BACD,0BACA,2BACA,6BACAA,uBACA;YAEQ,cAAc,sBAAsB;YAEpC,sBACV,yBAAyBC,SACzB,2BACE,+BAA8B,KAC9B,UAAUA,QACR,mBACE,GACA,QAAQ,oBAAoB;WAAe,UAAU;;YAKjD,mBAAmB,UAAUA,OAAY,kBAAkBC,UACrE,qCAIM,uBAAuB,KACvBC,YAAmB,iCACnBC,aAAoB,mCAClB,oDAGMC,UACA,uBAAuB,oBACvB,2BAA2B;qBAoJ9B,uBACX,yBACA,cAAc,OAAO,KACrB,eAAe,OAAO,KACtB,mCAAmCC,OAAgB,oBAEjC,UACR,UAAQ,uBACG,QACbC,eAAsB,OAAO,SAAO,aAC/B,mBAAiB,SACrB,kBAAa,OAAA,OAAA,cAAA,UAAA,iBAAA,2BAAAC,QAAA,YAAA,4BAAA,+BAAA,qDAAAH,UAAA,2BAAA,qBAAA,uBAAA;qBAYX,2BACX,yBACA,cAAc,OAAO,KACrB,eAAe,OAAO,KACtB,mCAAmCC,OAAgB,oBAEjC,UACR,UAAQ,uBACG,QACbC,eAAsB,OAAO,SAAO,aAC/B,mBAAiB,SACrB,kBAAa,OAAA,OAAA,cAAA,UAAA,OAAA,OAAA,2BAAAC,QAAA,YAAA,4BAAA,+BAAA,qDAAAH,UAAA,2BAAA,qBAAA,uBAAA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { handlerKey } from "../../Action.js";
|
|
2
|
+
import { findHandler, mergeUnder } from "../handler-context.js";
|
|
3
|
+
import { decodeJsonMapError } from "../schema-runtime.js";
|
|
4
|
+
import { authRuntimeContext, failConnectionIdNotAllowed, noAuthRuntimeContext, resolveRuntimeConnection, toNonEmptyArray } from "../auth-execution.js";
|
|
5
|
+
import { Effect, Schema, SchemaIssue } from "effect";
|
|
6
|
+
//#region src/internal/dual/invoke.ts
|
|
7
|
+
var FieldIssue = class extends Schema.Class("FieldIssue")({
|
|
8
|
+
message: Schema.String,
|
|
9
|
+
path: Schema.String
|
|
10
|
+
}) {};
|
|
11
|
+
var ActionNotFoundError = class extends Schema.TaggedError()("ActionNotFoundError", { actionId: Schema.String }) {};
|
|
12
|
+
var InvalidActionInputError = class extends Schema.TaggedError()("InvalidActionInputError", {
|
|
13
|
+
actionId: Schema.String,
|
|
14
|
+
description: Schema.String,
|
|
15
|
+
fields: Schema.Array(FieldIssue)
|
|
16
|
+
}) {};
|
|
17
|
+
var ActionHandlerNotFoundError = class extends Schema.TaggedError()("ActionHandlerNotFoundError", { actionId: Schema.String }) {};
|
|
18
|
+
var InvalidActionOutputError = class extends Schema.TaggedError()("InvalidActionOutputError", {
|
|
19
|
+
actionId: Schema.String,
|
|
20
|
+
description: Schema.String,
|
|
21
|
+
fields: Schema.Array(FieldIssue)
|
|
22
|
+
}) {};
|
|
23
|
+
const schemaIssueFormatter = SchemaIssue.makeFormatterStandardSchemaV1();
|
|
24
|
+
const formatFieldPath = (path) => {
|
|
25
|
+
let current = "$";
|
|
26
|
+
for (const segment of path) {
|
|
27
|
+
if (typeof segment === "number") {
|
|
28
|
+
current += `[${segment}]`;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const key = String(segment);
|
|
32
|
+
current += /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;
|
|
33
|
+
}
|
|
34
|
+
return current;
|
|
35
|
+
};
|
|
36
|
+
const schemaErrorFields = (error) => schemaIssueFormatter(error.issue).issues.map((issue) => new FieldIssue({
|
|
37
|
+
message: issue.message,
|
|
38
|
+
path: formatFieldPath(issue.path ?? [])
|
|
39
|
+
}));
|
|
40
|
+
const decodeActionInput = (actionId, schema, input) => decodeJsonMapError(schema, input, (error) => new InvalidActionInputError({
|
|
41
|
+
actionId,
|
|
42
|
+
description: error.message,
|
|
43
|
+
fields: schemaErrorFields(error)
|
|
44
|
+
}));
|
|
45
|
+
const validateActionOutput = (actionId, schema, output) => Schema.encodeEffect(schema)(output).pipe(Effect.as(output), Effect.mapError((error) => new InvalidActionOutputError({
|
|
46
|
+
actionId,
|
|
47
|
+
description: error.message,
|
|
48
|
+
fields: schemaErrorFields(error)
|
|
49
|
+
})));
|
|
50
|
+
const getActionHandler = (providerId, actionId) => Effect.context().pipe(Effect.flatMap((context) => {
|
|
51
|
+
const handler = findHandler(context, providerId, handlerKey(actionId));
|
|
52
|
+
return handler === void 0 ? Effect.fail(new ActionHandlerNotFoundError({ actionId })) : Effect.succeed(handler);
|
|
53
|
+
}));
|
|
54
|
+
const invokeResolvedActionWithOutput = (providerId, actionId, pluginVersion, action, authMethods, request, finish) => {
|
|
55
|
+
const requiredAuthMethods = toNonEmptyArray(authMethods);
|
|
56
|
+
if (requiredAuthMethods === void 0 && request.connectionId !== void 0) return failConnectionIdNotAllowed("action", actionId, void 0, providerId, request.connectionId);
|
|
57
|
+
return getActionHandler(providerId, actionId).pipe(Effect.flatMap((handler) => decodeActionInput(actionId, action.input, request.input).pipe(Effect.flatMap((decodedInput) => requiredAuthMethods === void 0 || action.requireAuth === false && request.connectionId === void 0 ? Effect.suspend(() => handler.handler(decodedInput, noAuthRuntimeContext())) : resolveRuntimeConnection("action", actionId, void 0, providerId, requiredAuthMethods, request.connectionId, request.context).pipe(Effect.flatMap((binding) => Effect.suspend(() => handler.handler(decodedInput, authRuntimeContext(binding)))))), Effect.updateContext((input) => mergeUnder(handler.context, input)))), Effect.flatMap(finish), Effect.map((data) => ({
|
|
58
|
+
data,
|
|
59
|
+
meta: {
|
|
60
|
+
actionId,
|
|
61
|
+
pluginVersion,
|
|
62
|
+
providerId
|
|
63
|
+
}
|
|
64
|
+
})));
|
|
65
|
+
};
|
|
66
|
+
const invokeResolvedAction = (providerId, actionId, pluginVersion, action, authMethods, request) => invokeResolvedActionWithOutput(providerId, actionId, pluginVersion, action, authMethods, request, (data) => validateActionOutput(actionId, action.output, data));
|
|
67
|
+
const invokeResolvedActionJson = (providerId, actionId, pluginVersion, action, authMethods, request) => invokeResolvedActionWithOutput(providerId, actionId, pluginVersion, action, authMethods, request, (data) => Schema.encodeUnknownEffect(Schema.toCodecJson(action.output))(data).pipe(Effect.mapError((error) => InvalidActionOutputError.make({
|
|
68
|
+
actionId,
|
|
69
|
+
description: error.message,
|
|
70
|
+
fields: schemaErrorFields(error)
|
|
71
|
+
}))));
|
|
72
|
+
//#endregion
|
|
73
|
+
export { ActionHandlerNotFoundError, ActionNotFoundError, FieldIssue, InvalidActionInputError, InvalidActionOutputError, invokeResolvedAction, invokeResolvedActionJson };
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=invoke.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke.js","names":["Action.handlerKey"],"sources":["../../../src/internal/dual/invoke.ts"],"sourcesContent":["import { Effect, Schema, SchemaIssue } from \"effect\";\n\nimport * as Action from \"../../Action.ts\";\nimport type * as AuthMethod from \"../../AuthMethod.ts\";\nimport type {\n ConnectionError,\n ConnectionResolutionContext,\n Service as ConnectionResolverService,\n} from \"../../ConnectionResolver.ts\";\nimport type * as Plugin from \"../../Plugin.ts\";\nimport {\n authRuntimeContext,\n failConnectionIdNotAllowed,\n noAuthRuntimeContext,\n resolveRuntimeConnection,\n type AuthResolutionRequirements,\n type AuthSchemaRequirements,\n toNonEmptyArray,\n} from \"../auth-execution.ts\";\nimport { findHandler, mergeUnder } from \"../handler-context.ts\";\nimport type { ActionHandlerServiceOf } from \"../plugin-handlers.ts\";\nimport { decodeJsonMapError } from \"../schema-runtime.ts\";\n\nimport type { PluginActionEntries } from \"./actions.ts\";\n\nexport interface InvokeRequest {\n readonly actionId: string;\n /** The exact plugin release the caller pinned; another installed release does not run. */\n readonly actionVersion?: string;\n readonly pluginKey?: string;\n readonly input: unknown;\n readonly connectionId?: string;\n readonly context?: ConnectionResolutionContext;\n}\n\nexport interface InvokeMeta<ActionId extends string = string> {\n readonly actionId: ActionId;\n readonly providerId: string;\n readonly pluginVersion: string;\n}\n\nexport interface InvokeSuccess<ActionId extends string = string, Data = unknown> {\n readonly data: Data;\n readonly meta: InvokeMeta<ActionId>;\n}\n\nexport class FieldIssue extends Schema.Class<FieldIssue>(\"FieldIssue\")({\n message: Schema.String,\n path: Schema.String,\n}) {}\n\nexport class ActionNotFoundError extends Schema.TaggedError<ActionNotFoundError>()(\n \"ActionNotFoundError\",\n { actionId: Schema.String },\n) {}\n\nexport class InvalidActionInputError extends Schema.TaggedError<InvalidActionInputError>()(\n \"InvalidActionInputError\",\n { actionId: Schema.String, description: Schema.String, fields: Schema.Array(FieldIssue) },\n) {}\n\nexport class ActionHandlerNotFoundError extends Schema.TaggedError<ActionHandlerNotFoundError>()(\n \"ActionHandlerNotFoundError\",\n { actionId: Schema.String },\n) {}\n\nexport class InvalidActionOutputError extends Schema.TaggedError<InvalidActionOutputError>()(\n \"InvalidActionOutputError\",\n { actionId: Schema.String, description: Schema.String, fields: Schema.Array(FieldIssue) },\n) {}\n\ntype InvokeResolvedActionError =\n | InvalidActionInputError\n | InvalidActionOutputError\n | ActionHandlerNotFoundError\n | Action.ActionHandlerFailure\n | ConnectionError;\n\nexport type InvokeError = ActionNotFoundError | InvokeResolvedActionError;\n\nexport type InvokeRequirementsFor<\n Plugins extends readonly Plugin.Any[],\n ActionId extends string,\n> = Plugins[number] extends infer P\n ? P extends Plugin.Any\n ? PluginRequirements<\n P,\n Extract<PluginActionEntries<P>, { readonly actionId: ActionId }>[\"action\"]\n >\n : never\n : never;\n\nexport type PluginRequirements<P extends Plugin.Any, ActionDef extends Action.Any> = [\n ActionDef,\n] extends [never]\n ? never\n :\n | ActionHandlerServiceOf<P>\n | Action.InputSchema<ActionDef>[\"DecodingServices\"]\n | Action.OutputSchema<ActionDef>[\"EncodingServices\"]\n | ([P[\"authMethods\"][number]] extends [never]\n ? never\n :\n | ConnectionResolverService\n | AuthSchemaRequirements<P[\"authMethods\"]>\n | AuthResolutionRequirements<P[\"authMethods\"]>);\n\nconst schemaIssueFormatter = SchemaIssue.makeFormatterStandardSchemaV1();\n\nconst formatFieldPath = (path: readonly unknown[]): string => {\n let current = \"$\";\n\n for (const segment of path) {\n if (typeof segment === \"number\") {\n current += `[${segment}]`;\n continue;\n }\n\n const key = String(segment);\n current += /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;\n }\n\n return current;\n};\n\nconst schemaErrorFields = (error: Schema.SchemaError): readonly FieldIssue[] =>\n schemaIssueFormatter(error.issue).issues.map(\n issue => new FieldIssue({ message: issue.message, path: formatFieldPath(issue.path ?? []) }),\n );\n\nconst decodeActionInput = <Input extends Schema.Top>(\n actionId: string,\n schema: Input,\n input: unknown,\n): Effect.Effect<Input[\"Type\"], InvalidActionInputError, Input[\"DecodingServices\"]> =>\n decodeJsonMapError(\n schema,\n input,\n error =>\n new InvalidActionInputError({\n actionId,\n description: error.message,\n fields: schemaErrorFields(error),\n }),\n );\n\nconst validateActionOutput = <Output extends Schema.Top>(\n actionId: string,\n schema: Output,\n output: Output[\"Type\"],\n): Effect.Effect<Output[\"Type\"], InvalidActionOutputError, Output[\"EncodingServices\"]> =>\n Schema.encodeEffect(schema)(output).pipe(\n Effect.as(output),\n Effect.mapError(\n error =>\n new InvalidActionOutputError({\n actionId,\n description: error.message,\n fields: schemaErrorFields(error),\n }),\n ),\n );\n\nconst getActionHandler = <ActionId extends string>(\n providerId: string,\n actionId: ActionId,\n): Effect.Effect<Action.Handler<ActionId>, ActionHandlerNotFoundError, Action.Handler<ActionId>> =>\n Effect.context<Action.Handler<ActionId>>().pipe(\n Effect.flatMap(context => {\n const handler = findHandler(context, providerId, Action.handlerKey(actionId)) as\n | Action.Handler<ActionId>\n | undefined;\n\n return handler === undefined\n ? Effect.fail(new ActionHandlerNotFoundError({ actionId }))\n : Effect.succeed(handler);\n }),\n );\n\nconst invokeResolvedActionWithOutput = <\n ActionId extends string,\n Input extends Schema.Top,\n Output extends Schema.Top,\n ActionAuthMethods extends readonly AuthMethod.Any[],\n OutputValue,\n>(\n providerId: string,\n actionId: ActionId,\n pluginVersion: string,\n action: Action.Action<string, Input, Output>,\n authMethods: ActionAuthMethods,\n request: InvokeRequest,\n finish: (\n output: unknown,\n ) => Effect.Effect<OutputValue, InvalidActionOutputError, Output[\"EncodingServices\"]>,\n): Effect.Effect<\n InvokeSuccess<ActionId, OutputValue>,\n InvokeResolvedActionError,\n | Action.Handler<ActionId>\n | Input[\"DecodingServices\"]\n | Output[\"EncodingServices\"]\n | ([ActionAuthMethods[number]] extends [never]\n ? never\n :\n | ConnectionResolverService\n | AuthSchemaRequirements<ActionAuthMethods>\n | AuthResolutionRequirements<ActionAuthMethods>)\n> => {\n const requiredAuthMethods = toNonEmptyArray(authMethods);\n\n if (requiredAuthMethods === undefined && request.connectionId !== undefined) {\n return failConnectionIdNotAllowed(\n \"action\",\n actionId,\n undefined,\n providerId,\n request.connectionId,\n );\n }\n\n return getActionHandler(providerId, actionId).pipe(\n Effect.flatMap(handler =>\n decodeActionInput(actionId, action.input, request.input).pipe(\n Effect.flatMap(decodedInput =>\n requiredAuthMethods === undefined ||\n // Only an explicit false skips auth for definitions built outside the SDK.\n (action.requireAuth === false && request.connectionId === undefined)\n ? Effect.suspend(() => handler.handler(decodedInput, noAuthRuntimeContext()))\n : resolveRuntimeConnection(\n \"action\",\n actionId,\n undefined,\n providerId,\n requiredAuthMethods,\n request.connectionId,\n request.context,\n ).pipe(\n Effect.flatMap(binding =>\n Effect.suspend(() => handler.handler(decodedInput, authRuntimeContext(binding))),\n ),\n ),\n ),\n Effect.updateContext(input => mergeUnder(handler.context, input)),\n ),\n ),\n Effect.flatMap(finish),\n Effect.map((data): InvokeSuccess<ActionId, OutputValue> => ({\n data,\n meta: { actionId, pluginVersion, providerId },\n })),\n );\n};\n\nexport const invokeResolvedAction = <\n ActionId extends string,\n Input extends Schema.Top,\n Output extends Schema.Top,\n ActionAuthMethods extends readonly AuthMethod.Any[],\n>(\n providerId: string,\n actionId: ActionId,\n pluginVersion: string,\n action: Action.Action<string, Input, Output>,\n authMethods: ActionAuthMethods,\n request: InvokeRequest,\n) =>\n invokeResolvedActionWithOutput(\n providerId,\n actionId,\n pluginVersion,\n action,\n authMethods,\n request,\n data => validateActionOutput(actionId, action.output, data as Output[\"Type\"]),\n );\n\nexport const invokeResolvedActionJson = <\n ActionId extends string,\n Input extends Schema.Top,\n Output extends Schema.Top,\n ActionAuthMethods extends readonly AuthMethod.Any[],\n>(\n providerId: string,\n actionId: ActionId,\n pluginVersion: string,\n action: Action.Action<string, Input, Output>,\n authMethods: ActionAuthMethods,\n request: InvokeRequest,\n) =>\n invokeResolvedActionWithOutput(\n providerId,\n actionId,\n pluginVersion,\n action,\n authMethods,\n request,\n data =>\n Schema.encodeUnknownEffect(Schema.toCodecJson(action.output))(data).pipe(\n Effect.mapError(error =>\n InvalidActionOutputError.make({\n actionId,\n description: error.message,\n fields: schemaErrorFields(error),\n }),\n ),\n ),\n );\n"],"mappings":";;;;;;AA8CA,IAAa,aAAb,cAAgC,OAAO,MAAkB,YAAY,CAAC,CAAC;CACrE,SAAS,OAAO;CAChB,MAAM,OAAO;AACf,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA,EAAE,UAAU,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ACA,eACA,QACA,aACA,UACA,SAAQ,qBAAqB,UAAU,OAAO,QAAQ,IAAsB,CAC9E;AAEF,MAAa,4BAMX,YACA,UACA,eACA,QACA,aACA,YAEA,+BACE,YACA,UACA,eACA,QACA,aACA,UACA,SACE,OAAO,oBAAoB,OAAO,YAAY,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAClE,OAAO,UAAS,UACd,yBAAyB,KAAK;CAC5B;CACA,aAAa,MAAM;CACnB,QAAQ,kBAAkB,KAAK;AACjC,CAAC,CACH,CACF,CACJ"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { AuthMethodKind } from "../../AuthMethod.js";
|
|
2
|
+
import { Exposure, Features, Protocol, RequiredChecks } from "../../AgentChannel.js";
|
|
3
|
+
import { Category } from "../../Plugin.js";
|
|
4
|
+
import { Any } from "../../AiProvider.js";
|
|
5
|
+
import { PluginInstallation } from "../../DualRuntime.js";
|
|
6
|
+
import { Schema } from "effect";
|
|
7
|
+
//#region src/internal/dual/registry.d.ts
|
|
8
|
+
export interface MaterializedRegistryOptions {
|
|
9
|
+
readonly schemaJson?: ((schema: Schema.Top) => unknown) | undefined;
|
|
10
|
+
readonly projections?: Map<Schema.Top, unknown> | undefined;
|
|
11
|
+
/** Selects the capability versions whose schemas are projected; the others carry `undefined` schemas. */
|
|
12
|
+
readonly projectSchemas?: ((capabilityId: string, version: string) => boolean) | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** @since 0.0.0 @category registry */
|
|
15
|
+
export interface MaterializedAuthMethod {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly providerId: string;
|
|
18
|
+
readonly key: string;
|
|
19
|
+
readonly name: string | undefined;
|
|
20
|
+
readonly description: string | undefined;
|
|
21
|
+
readonly kind: AuthMethodKind;
|
|
22
|
+
readonly setupSchemaJson: unknown | null;
|
|
23
|
+
readonly inputSchemaJson: unknown | null;
|
|
24
|
+
readonly materialSchemaJson: unknown;
|
|
25
|
+
readonly metadataJson: unknown;
|
|
26
|
+
}
|
|
27
|
+
/** @since 0.0.0 @category registry */
|
|
28
|
+
export interface MaterializedProvider {
|
|
29
|
+
readonly kind: "tools" | "ai";
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly key: string;
|
|
32
|
+
readonly name: string | undefined;
|
|
33
|
+
readonly description: string | undefined;
|
|
34
|
+
readonly iconUrl: string | undefined;
|
|
35
|
+
readonly iconUrlDark: string | undefined;
|
|
36
|
+
readonly categories: readonly Category[];
|
|
37
|
+
readonly homepageUrl: string | undefined;
|
|
38
|
+
readonly docsUrl: string | undefined;
|
|
39
|
+
/** Whether a shell in a run sandbox may use the provider's Connections through Dual's gateway. */
|
|
40
|
+
readonly sandboxAccess: boolean;
|
|
41
|
+
readonly sourcePluginKey: string | undefined;
|
|
42
|
+
readonly sourcePluginVersion: string | undefined;
|
|
43
|
+
readonly authMethods: readonly MaterializedAuthMethod[];
|
|
44
|
+
readonly capabilityVersions: readonly MaterializedCapabilityVersion[];
|
|
45
|
+
}
|
|
46
|
+
/** @since 0.0.0 @category registry */
|
|
47
|
+
export interface MaterializedActionCapabilityVersion {
|
|
48
|
+
readonly kind: "action";
|
|
49
|
+
readonly requireAuth: boolean;
|
|
50
|
+
readonly capabilityId: string;
|
|
51
|
+
readonly key: string;
|
|
52
|
+
readonly name: string | undefined;
|
|
53
|
+
readonly description: string | undefined;
|
|
54
|
+
readonly version: string;
|
|
55
|
+
readonly sourcePluginKey: string | undefined;
|
|
56
|
+
readonly sourcePluginVersion: string | undefined;
|
|
57
|
+
readonly authMethodIds: readonly string[];
|
|
58
|
+
readonly inputSchemaJson: unknown;
|
|
59
|
+
readonly outputSchemaJson: unknown;
|
|
60
|
+
readonly examplesJson: unknown;
|
|
61
|
+
}
|
|
62
|
+
/** @since 0.0.0 @category registry */
|
|
63
|
+
export interface MaterializedTriggerCapabilityVersion {
|
|
64
|
+
readonly kind: "trigger";
|
|
65
|
+
readonly requireAuth: boolean;
|
|
66
|
+
readonly capabilityId: string;
|
|
67
|
+
readonly key: string;
|
|
68
|
+
readonly name: string | undefined;
|
|
69
|
+
readonly description: string | undefined;
|
|
70
|
+
readonly version: string;
|
|
71
|
+
readonly sourcePluginKey: string | undefined;
|
|
72
|
+
readonly sourcePluginVersion: string | undefined;
|
|
73
|
+
readonly authMethodIds: readonly string[];
|
|
74
|
+
readonly triggerKind: "webhook" | "polling";
|
|
75
|
+
readonly configSchemaJson: unknown;
|
|
76
|
+
readonly outputSchemaJson: unknown;
|
|
77
|
+
readonly stateSchemaJson: unknown | undefined;
|
|
78
|
+
}
|
|
79
|
+
/** @since 0.0.0 @category registry */
|
|
80
|
+
export interface MaterializedChannelCapabilityVersion {
|
|
81
|
+
readonly kind: "agent_channel";
|
|
82
|
+
readonly requireAuth: boolean;
|
|
83
|
+
readonly capabilityId: string;
|
|
84
|
+
readonly key: string;
|
|
85
|
+
readonly name: string | undefined;
|
|
86
|
+
readonly description: string | undefined;
|
|
87
|
+
readonly version: string;
|
|
88
|
+
readonly sourcePluginKey: string | undefined;
|
|
89
|
+
readonly sourcePluginVersion: string | undefined;
|
|
90
|
+
readonly authMethodIds: readonly string[];
|
|
91
|
+
readonly definitionSettingsSchemaJson: unknown;
|
|
92
|
+
readonly deploymentSettingsSchemaJson: unknown;
|
|
93
|
+
readonly stateSchemaJson: unknown;
|
|
94
|
+
readonly operationInputSchemaJson: unknown;
|
|
95
|
+
readonly operationOutputSchemaJson: unknown;
|
|
96
|
+
readonly extensionsSchemaJson: Readonly<Record<string, unknown>>;
|
|
97
|
+
readonly featuresJson: Features;
|
|
98
|
+
readonly exposure: typeof Exposure.Type;
|
|
99
|
+
/** Absent for the original protocol. */
|
|
100
|
+
readonly protocol?: Protocol;
|
|
101
|
+
readonly requiredChecks: typeof RequiredChecks.Type;
|
|
102
|
+
}
|
|
103
|
+
export type MaterializedCapabilityVersion = MaterializedChannelCapabilityVersion | MaterializedActionCapabilityVersion | MaterializedTriggerCapabilityVersion;
|
|
104
|
+
/** @since 0.0.0 @category registry */
|
|
105
|
+
export interface MaterializedRegistry {
|
|
106
|
+
readonly dualIdentifier: string;
|
|
107
|
+
readonly providers: readonly MaterializedProvider[];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Materialize the provider/capability registry of the installed plugin releases. This is the
|
|
111
|
+
* canonical SDK-owned resolver used by server persistence/bootstrap code.
|
|
112
|
+
*
|
|
113
|
+
* @since 0.0.0
|
|
114
|
+
* @category registry
|
|
115
|
+
*/
|
|
116
|
+
export declare const materializeResolvedRegistry: (input: {
|
|
117
|
+
readonly dualIdentifier: string;
|
|
118
|
+
readonly plugins: readonly PluginInstallation[];
|
|
119
|
+
readonly aiProviders: readonly Any[];
|
|
120
|
+
readonly schemaJson?: ((schema: Schema.Top) => unknown) | undefined;
|
|
121
|
+
readonly projections?: Map<Schema.Top, unknown> | undefined;
|
|
122
|
+
readonly projectSchemas?: ((capabilityId: string, version: string) => boolean) | undefined;
|
|
123
|
+
}) => MaterializedRegistry;
|
|
124
|
+
//#endregion
|
|
125
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","names":["AuthMethod.AuthMethodKind","Plugin.Category","AgentChannel.Features","AgentChannel.Protocol","AiProvider.Any"],"sources":["../../../src/internal/dual/registry.ts"],"mappings":";;;;;;;iBAYiB;WACN,eAAe,QAAQ,OAAO;WAC9B,cAAc,IAAI,OAAO;;WAEzB,mBAAmB,sBAAsB;;;iBAInC;WACN;WACA;WACA;WACA;WACA;WACA,MAAMA;WACN;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA,qBAAqBC;WACrB;WACA;;WAEA;WACA;WACA;WACA,sBAAsB;WACtB,6BAA6B;;;iBAIvB;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,sBAAsB,SAAS;WAC/B,cAAcC;WACd,iBAAuC,SAAA;;WAEvC,WAAWC;WACX,uBAAmD,eAAA;;YAElD,gCACR,uCACA,sCACA;;iBAGa;WACN;WACA,oBAAoB;;;;;;;;;qBAsDlB,8BAA2B;WAC7B;WACA,kBAAkB;WAClB,sBAAsBC;WACtB,eAAe,QAAQ,OAAO;WAC9B,cAAc,IAAI,OAAO;WACzB,mBAAmB,sBAAsB;MAChD"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { projectContract, validateDefinition } from "../../AgentChannel.js";
|
|
2
|
+
import { registryId } from "../../AiProvider.js";
|
|
3
|
+
import { collectActionEntries } from "./actions.js";
|
|
4
|
+
import { collectTriggerEntries } from "./triggers.js";
|
|
5
|
+
import { Schema } from "effect";
|
|
6
|
+
//#region src/internal/dual/registry.ts
|
|
7
|
+
/** Materialized Dual registry DTOs and resolver. */
|
|
8
|
+
const authMethodId = (providerId, methodId) => `${providerId}/${methodId}`;
|
|
9
|
+
const schemaJson = (schema) => Schema.toJsonSchemaDocument(schema, { onExcessProperty: "error" });
|
|
10
|
+
const authMethodMetadataJson = (method) => {
|
|
11
|
+
if (method.oauth2 === void 0) return {};
|
|
12
|
+
const staticClient = typeof method.oauth2.client === "function" ? void 0 : method.oauth2.client;
|
|
13
|
+
const staticEndpoint = (endpoint) => typeof endpoint === "function" ? void 0 : endpoint;
|
|
14
|
+
const discoveryUrl = staticEndpoint(method.oauth2.discoveryUrl);
|
|
15
|
+
const authorizationUrl = staticEndpoint(method.oauth2.authorizationUrl);
|
|
16
|
+
const tokenUrl = staticEndpoint(method.oauth2.tokenUrl);
|
|
17
|
+
return { oauth2: {
|
|
18
|
+
scopes: method.oauth2.scopes,
|
|
19
|
+
...staticClient === void 0 ? {} : { clientAuthentication: staticClient.authentication ?? "basic" },
|
|
20
|
+
...discoveryUrl === void 0 ? {} : { discoveryUrl },
|
|
21
|
+
...authorizationUrl === void 0 ? {} : { authorizationUrl },
|
|
22
|
+
...tokenUrl === void 0 ? {} : { tokenUrl },
|
|
23
|
+
...method.oauth2.pkce === void 0 ? {} : { pkce: method.oauth2.pkce },
|
|
24
|
+
...method.oauth2.authorizationParams === void 0 ? {} : { authorizationParams: method.oauth2.authorizationParams },
|
|
25
|
+
...method.oauth2.tokenParams === void 0 ? {} : { tokenParams: method.oauth2.tokenParams }
|
|
26
|
+
} };
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Materialize the provider/capability registry of the installed plugin releases. This is the
|
|
30
|
+
* canonical SDK-owned resolver used by server persistence/bootstrap code.
|
|
31
|
+
*
|
|
32
|
+
* @since 0.0.0
|
|
33
|
+
* @category registry
|
|
34
|
+
*/
|
|
35
|
+
const materializeResolvedRegistry = (input) => {
|
|
36
|
+
const projectedSchemas = input.projections ?? /* @__PURE__ */ new Map();
|
|
37
|
+
const projectSchemaUncached = input.schemaJson ?? schemaJson;
|
|
38
|
+
const projectSchema = (schema) => {
|
|
39
|
+
if (projectedSchemas.has(schema)) return projectedSchemas.get(schema);
|
|
40
|
+
const projected = projectSchemaUncached(schema);
|
|
41
|
+
projectedSchemas.set(schema, projected);
|
|
42
|
+
return projected;
|
|
43
|
+
};
|
|
44
|
+
const projectSchemasFor = input.projectSchemas ?? (() => true);
|
|
45
|
+
const capabilityVersionsByProvider = /* @__PURE__ */ new Map();
|
|
46
|
+
const addCapabilityVersion = (providerId, capabilityVersion) => {
|
|
47
|
+
const versions = capabilityVersionsByProvider.get(providerId) ?? [];
|
|
48
|
+
versions.push(capabilityVersion);
|
|
49
|
+
capabilityVersionsByProvider.set(providerId, versions);
|
|
50
|
+
};
|
|
51
|
+
for (const entry of collectActionEntries(input.plugins)) {
|
|
52
|
+
const projected = projectSchemasFor(entry.actionId, entry.pluginVersion);
|
|
53
|
+
addCapabilityVersion(entry.providerId, {
|
|
54
|
+
authMethodIds: entry.authMethods.map((method) => authMethodId(entry.providerId, method.identifier)),
|
|
55
|
+
capabilityId: entry.actionId,
|
|
56
|
+
description: entry.action.description,
|
|
57
|
+
examplesJson: entry.action.examples,
|
|
58
|
+
inputSchemaJson: projected ? projectSchema(entry.action.input) : void 0,
|
|
59
|
+
key: entry.localId,
|
|
60
|
+
kind: "action",
|
|
61
|
+
requireAuth: entry.action.requireAuth !== false,
|
|
62
|
+
name: entry.action.name,
|
|
63
|
+
outputSchemaJson: projected ? projectSchema(entry.action.output) : void 0,
|
|
64
|
+
sourcePluginKey: entry.providerId,
|
|
65
|
+
sourcePluginVersion: entry.pluginVersion,
|
|
66
|
+
version: entry.pluginVersion
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
for (const entry of collectTriggerEntries(input.plugins)) {
|
|
70
|
+
const projected = projectSchemasFor(entry.triggerId, entry.pluginVersion);
|
|
71
|
+
addCapabilityVersion(entry.providerId, {
|
|
72
|
+
authMethodIds: entry.authMethods.map((method) => authMethodId(entry.providerId, method.identifier)),
|
|
73
|
+
capabilityId: entry.triggerId,
|
|
74
|
+
configSchemaJson: projected ? projectSchema(entry.trigger.config) : void 0,
|
|
75
|
+
description: entry.trigger.description,
|
|
76
|
+
key: entry.localId,
|
|
77
|
+
kind: "trigger",
|
|
78
|
+
requireAuth: entry.trigger.requireAuth !== false,
|
|
79
|
+
name: entry.trigger.name,
|
|
80
|
+
outputSchemaJson: projected ? projectSchema(entry.trigger.output) : void 0,
|
|
81
|
+
sourcePluginKey: entry.providerId,
|
|
82
|
+
sourcePluginVersion: entry.pluginVersion,
|
|
83
|
+
stateSchemaJson: projected && entry.trigger.state !== void 0 ? projectSchema(entry.trigger.state) : void 0,
|
|
84
|
+
triggerKind: entry.trigger.kind,
|
|
85
|
+
version: entry.pluginVersion
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
for (const { plugin, version } of input.plugins) for (const channel of plugin.agentChannels) {
|
|
89
|
+
const definition = channel.definition;
|
|
90
|
+
validateDefinition(definition, plugin.identifier, plugin.authMethods);
|
|
91
|
+
addCapabilityVersion(plugin.identifier, {
|
|
92
|
+
authMethodIds: definition.authMethods.map((method) => authMethodId(plugin.identifier, method.identifier)),
|
|
93
|
+
capabilityId: `${plugin.identifier}/${channel.identifier}`,
|
|
94
|
+
description: channel.description,
|
|
95
|
+
key: channel.identifier,
|
|
96
|
+
kind: "agent_channel",
|
|
97
|
+
requireAuth: true,
|
|
98
|
+
name: channel.name,
|
|
99
|
+
sourcePluginKey: plugin.identifier,
|
|
100
|
+
sourcePluginVersion: version,
|
|
101
|
+
version,
|
|
102
|
+
...projectContract(definition, projectSchema)
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const toolProviders = input.plugins.map(({ plugin, version }) => ({
|
|
106
|
+
authMethods: plugin.authMethods.map((method) => ({
|
|
107
|
+
description: method.description,
|
|
108
|
+
id: authMethodId(plugin.identifier, method.identifier),
|
|
109
|
+
inputSchemaJson: method.input === void 0 ? null : projectSchema(method.input),
|
|
110
|
+
key: method.identifier,
|
|
111
|
+
kind: method.kind,
|
|
112
|
+
materialSchemaJson: projectSchema(method.material),
|
|
113
|
+
metadataJson: authMethodMetadataJson(method),
|
|
114
|
+
name: method.name,
|
|
115
|
+
providerId: plugin.identifier,
|
|
116
|
+
setupSchemaJson: method.setup === void 0 ? null : projectSchema(method.setup)
|
|
117
|
+
})),
|
|
118
|
+
capabilityVersions: capabilityVersionsByProvider.get(plugin.identifier) ?? [],
|
|
119
|
+
categories: plugin.categories,
|
|
120
|
+
description: plugin.description,
|
|
121
|
+
docsUrl: plugin.docsUrl,
|
|
122
|
+
homepageUrl: plugin.homepageUrl,
|
|
123
|
+
iconUrl: plugin.iconUrl,
|
|
124
|
+
iconUrlDark: plugin.iconUrlDark,
|
|
125
|
+
id: plugin.identifier,
|
|
126
|
+
key: plugin.identifier,
|
|
127
|
+
kind: "tools",
|
|
128
|
+
name: plugin.name,
|
|
129
|
+
sandboxAccess: plugin.sandboxAccess !== void 0,
|
|
130
|
+
sourcePluginKey: plugin.identifier,
|
|
131
|
+
sourcePluginVersion: version
|
|
132
|
+
}));
|
|
133
|
+
const aiProviders = input.aiProviders.flatMap((provider) => {
|
|
134
|
+
const id = registryId(provider.identifier);
|
|
135
|
+
return [{
|
|
136
|
+
authMethods: provider.authMethods.map((method) => ({
|
|
137
|
+
description: method.description,
|
|
138
|
+
id: authMethodId(id, method.identifier),
|
|
139
|
+
inputSchemaJson: method.input === void 0 ? null : projectSchema(method.input),
|
|
140
|
+
key: method.identifier,
|
|
141
|
+
kind: method.kind,
|
|
142
|
+
materialSchemaJson: projectSchema(method.material),
|
|
143
|
+
metadataJson: authMethodMetadataJson(method),
|
|
144
|
+
name: method.name,
|
|
145
|
+
providerId: id,
|
|
146
|
+
setupSchemaJson: method.setup === void 0 ? null : projectSchema(method.setup)
|
|
147
|
+
})),
|
|
148
|
+
capabilityVersions: [],
|
|
149
|
+
categories: provider.categories,
|
|
150
|
+
description: provider.description,
|
|
151
|
+
docsUrl: provider.docsUrl,
|
|
152
|
+
homepageUrl: provider.homepageUrl,
|
|
153
|
+
iconUrl: provider.iconUrl,
|
|
154
|
+
iconUrlDark: provider.iconUrlDark,
|
|
155
|
+
id,
|
|
156
|
+
key: provider.identifier,
|
|
157
|
+
kind: "ai",
|
|
158
|
+
name: provider.name,
|
|
159
|
+
sandboxAccess: false,
|
|
160
|
+
sourcePluginKey: void 0,
|
|
161
|
+
sourcePluginVersion: void 0
|
|
162
|
+
}];
|
|
163
|
+
});
|
|
164
|
+
return {
|
|
165
|
+
dualIdentifier: input.dualIdentifier,
|
|
166
|
+
providers: [...toolProviders, ...aiProviders]
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
//#endregion
|
|
170
|
+
export { materializeResolvedRegistry };
|
|
171
|
+
|
|
172
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","names":["AgentChannel.projectContract","AiProvider.registryId"],"sources":["../../../src/internal/dual/registry.ts"],"sourcesContent":["/** Materialized Dual registry DTOs and resolver. */\nimport { Schema } from \"effect\";\n\nimport * as AgentChannel from \"../../AgentChannel.ts\";\nimport * as AiProvider from \"../../AiProvider.ts\";\nimport type * as AuthMethod from \"../../AuthMethod.ts\";\nimport type { PluginInstallation } from \"../../DualRuntime.ts\";\nimport type * as Plugin from \"../../Plugin.ts\";\n\nimport { collectActionEntries } from \"./actions.ts\";\nimport { collectTriggerEntries } from \"./triggers.ts\";\n\nexport interface MaterializedRegistryOptions {\n readonly schemaJson?: ((schema: Schema.Top) => unknown) | undefined;\n readonly projections?: Map<Schema.Top, unknown> | undefined;\n /** Selects the capability versions whose schemas are projected; the others carry `undefined` schemas. */\n readonly projectSchemas?: ((capabilityId: string, version: string) => boolean) | undefined;\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedAuthMethod {\n readonly id: string;\n readonly providerId: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly kind: AuthMethod.AuthMethodKind;\n readonly setupSchemaJson: unknown | null;\n readonly inputSchemaJson: unknown | null;\n readonly materialSchemaJson: unknown;\n readonly metadataJson: unknown;\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedProvider {\n readonly kind: \"tools\" | \"ai\";\n readonly id: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly iconUrl: string | undefined;\n readonly iconUrlDark: string | undefined;\n readonly categories: readonly Plugin.Category[];\n readonly homepageUrl: string | undefined;\n readonly docsUrl: string | undefined;\n /** Whether a shell in a run sandbox may use the provider's Connections through Dual's gateway. */\n readonly sandboxAccess: boolean;\n readonly sourcePluginKey: string | undefined;\n readonly sourcePluginVersion: string | undefined;\n readonly authMethods: readonly MaterializedAuthMethod[];\n readonly capabilityVersions: readonly MaterializedCapabilityVersion[];\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedActionCapabilityVersion {\n readonly kind: \"action\";\n readonly requireAuth: boolean;\n readonly capabilityId: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly version: string;\n readonly sourcePluginKey: string | undefined;\n readonly sourcePluginVersion: string | undefined;\n readonly authMethodIds: readonly string[];\n readonly inputSchemaJson: unknown;\n readonly outputSchemaJson: unknown;\n readonly examplesJson: unknown;\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedTriggerCapabilityVersion {\n readonly kind: \"trigger\";\n readonly requireAuth: boolean;\n readonly capabilityId: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly version: string;\n readonly sourcePluginKey: string | undefined;\n readonly sourcePluginVersion: string | undefined;\n readonly authMethodIds: readonly string[];\n readonly triggerKind: \"webhook\" | \"polling\";\n readonly configSchemaJson: unknown;\n readonly outputSchemaJson: unknown;\n readonly stateSchemaJson: unknown | undefined;\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedChannelCapabilityVersion {\n readonly kind: \"agent_channel\";\n readonly requireAuth: boolean;\n readonly capabilityId: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly version: string;\n readonly sourcePluginKey: string | undefined;\n readonly sourcePluginVersion: string | undefined;\n readonly authMethodIds: readonly string[];\n readonly definitionSettingsSchemaJson: unknown;\n readonly deploymentSettingsSchemaJson: unknown;\n readonly stateSchemaJson: unknown;\n readonly operationInputSchemaJson: unknown;\n readonly operationOutputSchemaJson: unknown;\n readonly extensionsSchemaJson: Readonly<Record<string, unknown>>;\n readonly featuresJson: AgentChannel.Features;\n readonly exposure: typeof AgentChannel.Exposure.Type;\n /** Absent for the original protocol. */\n readonly protocol?: AgentChannel.Protocol;\n readonly requiredChecks: typeof AgentChannel.RequiredChecks.Type;\n}\nexport type MaterializedCapabilityVersion =\n | MaterializedChannelCapabilityVersion\n | MaterializedActionCapabilityVersion\n | MaterializedTriggerCapabilityVersion;\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedRegistry {\n readonly dualIdentifier: string;\n readonly providers: readonly MaterializedProvider[];\n}\n\nconst authMethodId = (providerId: string, methodId: string): string => `${providerId}/${methodId}`;\n\n// FIXME(live-schema-validation): this JSON Schema is a lossy catalog/snapshot projection.\n// Hard validation must use the live SDK Schema declarations for the pinned version.\nconst schemaJson = (schema: Schema.Top): unknown =>\n Schema.toJsonSchemaDocument(schema, { onExcessProperty: \"error\" });\n\nconst authMethodMetadataJson = (method: AuthMethod.Any): unknown => {\n if (method.oauth2 === undefined) {\n return {};\n }\n\n const staticClient =\n typeof method.oauth2.client === \"function\" ? undefined : method.oauth2.client;\n\n // An endpoint derived from the setup has no value until a connection supplies\n // one, so the registry — which describes the method, not a connection — omits\n // it, exactly as it already omits a client built by a hook.\n const staticEndpoint = (endpoint: string | ((...args: never) => string) | undefined) =>\n typeof endpoint === \"function\" ? undefined : endpoint;\n const discoveryUrl = staticEndpoint(method.oauth2.discoveryUrl);\n const authorizationUrl = staticEndpoint(method.oauth2.authorizationUrl);\n const tokenUrl = staticEndpoint(method.oauth2.tokenUrl);\n\n return {\n oauth2: {\n scopes: method.oauth2.scopes,\n ...(staticClient === undefined\n ? {}\n : { clientAuthentication: staticClient.authentication ?? \"basic\" }),\n ...(discoveryUrl === undefined ? {} : { discoveryUrl }),\n ...(authorizationUrl === undefined ? {} : { authorizationUrl }),\n ...(tokenUrl === undefined ? {} : { tokenUrl }),\n ...(method.oauth2.pkce === undefined ? {} : { pkce: method.oauth2.pkce }),\n ...(method.oauth2.authorizationParams === undefined\n ? {}\n : { authorizationParams: method.oauth2.authorizationParams }),\n ...(method.oauth2.tokenParams === undefined\n ? {}\n : { tokenParams: method.oauth2.tokenParams }),\n },\n };\n};\n\n/**\n * Materialize the provider/capability registry of the installed plugin releases. This is the\n * canonical SDK-owned resolver used by server persistence/bootstrap code.\n *\n * @since 0.0.0\n * @category registry\n */\nexport const materializeResolvedRegistry = (input: {\n readonly dualIdentifier: string;\n readonly plugins: readonly PluginInstallation[];\n readonly aiProviders: readonly AiProvider.Any[];\n readonly schemaJson?: ((schema: Schema.Top) => unknown) | undefined;\n readonly projections?: Map<Schema.Top, unknown> | undefined;\n readonly projectSchemas?: ((capabilityId: string, version: string) => boolean) | undefined;\n}): MaterializedRegistry => {\n // Plugins reuse schema values across capabilities, auth methods and app\n // versions, so project each one once per materialization. The memo is dropped\n // with the caller's materialization rather than retaining every projection for\n // the lifetime of the app definition.\n const projectedSchemas = input.projections ?? new Map<Schema.Top, unknown>();\n const projectSchemaUncached = input.schemaJson ?? schemaJson;\n const projectSchema = (schema: Schema.Top): unknown => {\n if (projectedSchemas.has(schema)) return projectedSchemas.get(schema);\n const projected = projectSchemaUncached(schema);\n projectedSchemas.set(schema, projected);\n return projected;\n };\n const projectSchemasFor = input.projectSchemas ?? (() => true);\n const capabilityVersionsByProvider = new Map<string, MaterializedCapabilityVersion[]>();\n const addCapabilityVersion = (\n providerId: string,\n capabilityVersion: MaterializedCapabilityVersion,\n ) => {\n const versions = capabilityVersionsByProvider.get(providerId) ?? [];\n versions.push(capabilityVersion);\n capabilityVersionsByProvider.set(providerId, versions);\n };\n\n for (const entry of collectActionEntries(input.plugins)) {\n const projected = projectSchemasFor(entry.actionId, entry.pluginVersion);\n addCapabilityVersion(entry.providerId, {\n authMethodIds: entry.authMethods.map(method =>\n authMethodId(entry.providerId, method.identifier),\n ),\n capabilityId: entry.actionId,\n description: entry.action.description,\n examplesJson: entry.action.examples,\n inputSchemaJson: projected ? projectSchema(entry.action.input) : undefined,\n key: entry.localId,\n kind: \"action\" as const,\n requireAuth: entry.action.requireAuth !== false,\n name: entry.action.name,\n outputSchemaJson: projected ? projectSchema(entry.action.output) : undefined,\n sourcePluginKey: entry.providerId,\n sourcePluginVersion: entry.pluginVersion,\n version: entry.pluginVersion,\n });\n }\n\n for (const entry of collectTriggerEntries(input.plugins)) {\n const projected = projectSchemasFor(entry.triggerId, entry.pluginVersion);\n addCapabilityVersion(entry.providerId, {\n authMethodIds: entry.authMethods.map(method =>\n authMethodId(entry.providerId, method.identifier),\n ),\n capabilityId: entry.triggerId,\n configSchemaJson: projected ? projectSchema(entry.trigger.config) : undefined,\n description: entry.trigger.description,\n key: entry.localId,\n kind: \"trigger\" as const,\n requireAuth: entry.trigger.requireAuth !== false,\n name: entry.trigger.name,\n outputSchemaJson: projected ? projectSchema(entry.trigger.output) : undefined,\n sourcePluginKey: entry.providerId,\n sourcePluginVersion: entry.pluginVersion,\n stateSchemaJson:\n projected && entry.trigger.state !== undefined\n ? projectSchema(entry.trigger.state)\n : undefined,\n triggerKind: entry.trigger.kind,\n version: entry.pluginVersion,\n });\n }\n\n for (const { plugin, version } of input.plugins) {\n for (const channel of plugin.agentChannels) {\n const definition = channel.definition;\n AgentChannel.validateDefinition(definition, plugin.identifier, plugin.authMethods);\n addCapabilityVersion(plugin.identifier, {\n authMethodIds: definition.authMethods.map(method =>\n authMethodId(plugin.identifier, method.identifier),\n ),\n capabilityId: `${plugin.identifier}/${channel.identifier}`,\n description: channel.description,\n key: channel.identifier,\n kind: \"agent_channel\",\n requireAuth: true,\n name: channel.name,\n sourcePluginKey: plugin.identifier,\n sourcePluginVersion: version,\n version,\n ...AgentChannel.projectContract(definition, projectSchema),\n });\n }\n }\n const toolProviders: readonly MaterializedProvider[] = input.plugins.map(\n ({ plugin, version }) => ({\n authMethods: plugin.authMethods.map(method => ({\n description: method.description,\n id: authMethodId(plugin.identifier, method.identifier),\n inputSchemaJson: method.input === undefined ? null : projectSchema(method.input),\n key: method.identifier,\n kind: method.kind,\n materialSchemaJson: projectSchema(method.material),\n metadataJson: authMethodMetadataJson(method),\n name: method.name,\n providerId: plugin.identifier,\n setupSchemaJson: method.setup === undefined ? null : projectSchema(method.setup),\n })),\n capabilityVersions: capabilityVersionsByProvider.get(plugin.identifier) ?? [],\n categories: plugin.categories,\n description: plugin.description,\n docsUrl: plugin.docsUrl,\n homepageUrl: plugin.homepageUrl,\n iconUrl: plugin.iconUrl,\n iconUrlDark: plugin.iconUrlDark,\n id: plugin.identifier,\n key: plugin.identifier,\n kind: \"tools\" as const,\n name: plugin.name,\n sandboxAccess: plugin.sandboxAccess !== undefined,\n sourcePluginKey: plugin.identifier,\n sourcePluginVersion: version,\n }),\n );\n\n const aiProviders: readonly MaterializedProvider[] = input.aiProviders.flatMap(provider => {\n const id = AiProvider.registryId(provider.identifier);\n\n return [\n {\n authMethods: provider.authMethods.map(method => ({\n description: method.description,\n id: authMethodId(id, method.identifier),\n inputSchemaJson: method.input === undefined ? null : projectSchema(method.input),\n key: method.identifier,\n kind: method.kind,\n materialSchemaJson: projectSchema(method.material),\n metadataJson: authMethodMetadataJson(method),\n name: method.name,\n providerId: id,\n setupSchemaJson: method.setup === undefined ? null : projectSchema(method.setup),\n })),\n capabilityVersions: [],\n categories: provider.categories,\n description: provider.description,\n docsUrl: provider.docsUrl,\n homepageUrl: provider.homepageUrl,\n iconUrl: provider.iconUrl,\n iconUrlDark: provider.iconUrlDark,\n id,\n key: provider.identifier,\n kind: \"ai\" as const,\n name: provider.name,\n sandboxAccess: false,\n sourcePluginKey: undefined,\n sourcePluginVersion: undefined,\n },\n ];\n });\n\n return { dualIdentifier: input.dualIdentifier, providers: [...toolProviders, ...aiProviders] };\n};\n"],"mappings":";;;;;;;AA2HA,MAAM,gBAAgB,YAAoB,aAA6B,GAAG,WAAW,GAAG;AAIxF,MAAM,cAAc,WAClB,OAAO,qBAAqB,QAAQ,EAAE,kBAAkB,QAAQ,CAAC;AAEnE,MAAM,0BAA0B,WAAoC;CAClE,IAAI,OAAO,WAAW,KAAA,GACpB,OAAO,CAAC;CAGV,MAAM,eACJ,OAAO,OAAO,OAAO,WAAW,aAAa,KAAA,IAAY,OAAO,OAAO;CAKzE,MAAM,kBAAkB,aACtB,OAAO,aAAa,aAAa,KAAA,IAAY;CAC/C,MAAM,eAAe,eAAe,OAAO,OAAO,YAAY;CAC9D,MAAM,mBAAmB,eAAe,OAAO,OAAO,gBAAgB;CACt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AiB,OAAO,UAAU,KAAA,IAAY,OAAO,cAAc,OAAO,KAAK;IAC/E,KAAK,OAAO;IACZ,MAAM,OAAO;IACb,oBAAoB,cAAc,OAAO,QAAQ;IACjD,cAAc,uBAAuB,MAAM;IAC3C,MAAM,OAAO;IACb,YAAY;IACZ,iBAAiB,OAAO,UAAU,KAAA,IAAY,OAAO,cAAc,OAAO,KAAK;GACjF,EAAE;GACF,oBAAoB,CAAC;GACrB,YAAY,SAAS;GACrB,aAAa,SAAS;GACtB,SAAS,SAAS;GAClB,aAAa,SAAS;GACtB,SAAS,SAAS;GAClB,aAAa,SAAS;GACtB;GACA,KAAK,SAAS;GACd,MAAM;GACN,MAAM,SAAS;GACf,eAAe;GACf,iBAAiB,KAAA;GACjB,qBAAqB,KAAA;EACvB,CACF;CACF,CAAC;CAED,OAAO;EAAE,gBAAgB,MAAM;EAAgB,WAAW,CAAC,GAAG,eAAe,GAAG,WAAW;CAAE;AAC/F"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Any } from "../../AuthMethod.js";
|
|
2
|
+
import { Any as Any$1, RuntimeTriggerEntry as RuntimeTriggerEntry$1 } from "../../Trigger.js";
|
|
3
|
+
import { Any as Any$2 } from "../../Group.js";
|
|
4
|
+
import { MachineIdSeparator } from "../identifier.js";
|
|
5
|
+
import { IsAny, IsGenericArray } from "../types.js";
|
|
6
|
+
import { Any as Any$3 } from "../../Plugin.js";
|
|
7
|
+
import { PluginInstallation } from "../../DualRuntime.js";
|
|
8
|
+
//#region src/internal/dual/triggers.d.ts
|
|
9
|
+
export interface TriggerEntry<Id extends string = string, ProviderId extends string = string, TriggerDef extends Any$1 = Any$1, AllowedMethods extends readonly Any[] = readonly Any[]> {
|
|
10
|
+
readonly triggerId: Id;
|
|
11
|
+
readonly providerId: ProviderId;
|
|
12
|
+
readonly trigger: TriggerDef;
|
|
13
|
+
readonly authMethods: AllowedMethods;
|
|
14
|
+
}
|
|
15
|
+
type TriggerEntriesFromTriggers<Triggers extends readonly Any$1[], ProviderId extends string, Prefix extends string, AllowedMethods extends readonly Any[]> = IsGenericArray<Triggers> extends true ? TriggerEntry<string, ProviderId, Any$1, AllowedMethods> : Triggers[number] extends (infer TriggerDef) ? TriggerDef extends Any$1 ? TriggerEntry<`${Prefix}${typeof MachineIdSeparator}${TriggerDef["identifier"]}`, ProviderId, TriggerDef, AllowedMethods> : never : never;
|
|
16
|
+
type TriggerEntriesFromGroups<Groups extends readonly Any$2[], ProviderId extends string, Prefix extends string, AllowedMethods extends readonly Any[]> = IsGenericArray<Groups> extends true ? TriggerEntry<string, ProviderId, Any$1, AllowedMethods> : Groups[number] extends (infer GroupDef) ? GroupDef extends Any$2 ? GroupTriggerEntries<GroupDef, ProviderId, `${Prefix}${typeof MachineIdSeparator}${GroupDef["identifier"]}`, AllowedMethods> : never : never;
|
|
17
|
+
type GroupTriggerEntries<GroupDef extends Any$2, ProviderId extends string, Prefix extends string, AllowedMethods extends readonly Any[]> = TriggerEntriesFromTriggers<GroupDef["triggers"], ProviderId, Prefix, AllowedMethods> | TriggerEntriesFromGroups<GroupDef["groups"], ProviderId, Prefix, AllowedMethods>;
|
|
18
|
+
type PluginTriggerEntries<P extends Any$3> = TriggerEntriesFromTriggers<P["triggers"], P["identifier"], P["identifier"], P["authMethods"]> | TriggerEntriesFromGroups<P["groups"], P["identifier"], P["identifier"], P["authMethods"]>;
|
|
19
|
+
export type AllTriggerEntries<Plugins extends readonly Any$3[]> = IsAny<Plugins> extends true ? TriggerEntry : IsGenericArray<Plugins> extends true ? TriggerEntry : Plugins[number] extends (infer P) ? P extends Any$3 ? PluginTriggerEntries<P> : never : never;
|
|
20
|
+
export interface RuntimeTriggerEntry<out TriggerDef extends Any$1 = Any$1, out AllowedMethods extends readonly Any[] = readonly Any[], out TriggerId extends string = string, out ProviderId extends string = string> extends RuntimeTriggerEntry$1<TriggerDef, AllowedMethods, TriggerId, ProviderId> {
|
|
21
|
+
readonly localId: string;
|
|
22
|
+
readonly pluginVersion: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const collectTriggerEntries: (installations: readonly PluginInstallation[]) => readonly RuntimeTriggerEntry[];
|
|
25
|
+
/** A trigger of the installed releases, or of the exact `version` when the caller pins one. */
|
|
26
|
+
export declare const resolveRuntimeTrigger: (installations: readonly PluginInstallation[], triggerId: string, version?: string) => RuntimeTriggerEntry | undefined;
|
|
27
|
+
//#endregion
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=triggers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triggers.d.ts","names":["Trigger.Any","AuthMethod.Any","Group.Any","Plugin.Any","Trigger.RuntimeTriggerEntry"],"sources":["../../../src/internal/dual/triggers.ts"],"mappings":";;;;;;;;iBASiB,aACf,4BACA,oCACA,mBAAmBA,QAAcA,OACjC,gCAAgCC,iBAA4BA;WAEnD,WAAW;WACX,YAAY;WACZ,SAAS;WACT,aAAa;;KAGnB,2BACH,0BAA0BD,SAC1B,2BACA,uBACA,gCAAgCC,SAEhC,eAAe,yBACX,qBAAqB,YAAYD,OAAa,kBAC9C,gCAA+B,cAC7B,mBAAmBA,QACjB,gBACK,gBAAgB,qBAAqB,4BACxC,YACA,YACA;KAKP,yBACH,wBAAwBE,SACxB,2BACA,uBACA,gCAAgCD,SAEhC,eAAe,uBACX,qBAAqB,YAAYD,OAAa,kBAC9C,8BAA6B,YAC3B,iBAAiBE,QACf,oBACE,UACA,eACG,gBAAgB,qBAAqB,0BACxC;KAKP,oBACH,iBAAiBA,OACjB,2BACA,uBACA,gCAAgCD,SAE9B,2BAA2B,sBAAsB,YAAY,QAAQ,kBACrE,yBAAyB,oBAAoB,YAAY,QAAQ;KAEhE,qBAAqB,UAAUE,SAChC,2BAA2B,eAAe,iBAAiB,iBAAiB,oBAC5E,yBAAyB,aAAa,iBAAiB,iBAAiB;YAEhE,kBAAkB,yBAAyBA,WACrD,MAAM,wBACF,eACA,eAAe,wBACb,eACA,+BAA8B,KAC5B,UAAUA,QACR,qBAAqB;iBAIhB,wBACX,mBAAmBH,QAAcA,WACjC,gCAAgCC,iBAA4BA,WAC5D,uCACA,4CACIG,sBAA4B,YAAY,gBAAgB,WAAW;WAClE;WACA;;qBAaE,wBAAqB,wBACR,kCACd;;qBAQC,wBAAqB,wBACR,sBAAoB,mBAC3B,qBAEhB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { walkCapabilities } from "../capabilities.js";
|
|
2
|
+
//#region src/internal/dual/triggers.ts
|
|
3
|
+
const entriesOf = (installation) => walkCapabilities(installation.plugin, (owner) => owner.triggers).map((walked) => ({
|
|
4
|
+
authMethods: installation.plugin.authMethods,
|
|
5
|
+
localId: walked.localId,
|
|
6
|
+
pluginVersion: installation.version,
|
|
7
|
+
providerId: installation.plugin.identifier,
|
|
8
|
+
trigger: walked.node,
|
|
9
|
+
triggerId: walked.canonicalId
|
|
10
|
+
}));
|
|
11
|
+
const collectTriggerEntries = (installations) => installations.flatMap(entriesOf);
|
|
12
|
+
const triggerIndex = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
/** A trigger of the installed releases, or of the exact `version` when the caller pins one. */
|
|
14
|
+
const resolveRuntimeTrigger = (installations, triggerId, version) => {
|
|
15
|
+
let index = triggerIndex.get(installations);
|
|
16
|
+
if (index === void 0) {
|
|
17
|
+
index = new Map(collectTriggerEntries(installations).map((entry) => [entry.triggerId, entry]));
|
|
18
|
+
triggerIndex.set(installations, index);
|
|
19
|
+
}
|
|
20
|
+
const entry = index.get(triggerId);
|
|
21
|
+
return entry === void 0 || version !== void 0 && entry.pluginVersion !== version ? void 0 : entry;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { collectTriggerEntries, resolveRuntimeTrigger };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=triggers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triggers.js","names":[],"sources":["../../../src/internal/dual/triggers.ts"],"sourcesContent":["import type * as AuthMethod from \"../../AuthMethod.ts\";\nimport type { PluginInstallation } from \"../../DualRuntime.ts\";\nimport type * as Group from \"../../Group.ts\";\nimport type * as Plugin from \"../../Plugin.ts\";\nimport type * as Trigger from \"../../Trigger.ts\";\nimport { walkCapabilities } from \"../capabilities.ts\";\nimport type { MachineIdSeparator } from \"../identifier.ts\";\nimport type { IsAny, IsGenericArray } from \"../types.ts\";\n\nexport interface TriggerEntry<\n Id extends string = string,\n ProviderId extends string = string,\n TriggerDef extends Trigger.Any = Trigger.Any,\n AllowedMethods extends readonly AuthMethod.Any[] = readonly AuthMethod.Any[],\n> {\n readonly triggerId: Id;\n readonly providerId: ProviderId;\n readonly trigger: TriggerDef;\n readonly authMethods: AllowedMethods;\n}\n\ntype TriggerEntriesFromTriggers<\n Triggers extends readonly Trigger.Any[],\n ProviderId extends string,\n Prefix extends string,\n AllowedMethods extends readonly AuthMethod.Any[],\n> =\n IsGenericArray<Triggers> extends true\n ? TriggerEntry<string, ProviderId, Trigger.Any, AllowedMethods>\n : Triggers[number] extends infer TriggerDef\n ? TriggerDef extends Trigger.Any\n ? TriggerEntry<\n `${Prefix}${typeof MachineIdSeparator}${TriggerDef[\"identifier\"]}`,\n ProviderId,\n TriggerDef,\n AllowedMethods\n >\n : never\n : never;\n\ntype TriggerEntriesFromGroups<\n Groups extends readonly Group.Any[],\n ProviderId extends string,\n Prefix extends string,\n AllowedMethods extends readonly AuthMethod.Any[],\n> =\n IsGenericArray<Groups> extends true\n ? TriggerEntry<string, ProviderId, Trigger.Any, AllowedMethods>\n : Groups[number] extends infer GroupDef\n ? GroupDef extends Group.Any\n ? GroupTriggerEntries<\n GroupDef,\n ProviderId,\n `${Prefix}${typeof MachineIdSeparator}${GroupDef[\"identifier\"]}`,\n AllowedMethods\n >\n : never\n : never;\n\ntype GroupTriggerEntries<\n GroupDef extends Group.Any,\n ProviderId extends string,\n Prefix extends string,\n AllowedMethods extends readonly AuthMethod.Any[],\n> =\n | TriggerEntriesFromTriggers<GroupDef[\"triggers\"], ProviderId, Prefix, AllowedMethods>\n | TriggerEntriesFromGroups<GroupDef[\"groups\"], ProviderId, Prefix, AllowedMethods>;\n\ntype PluginTriggerEntries<P extends Plugin.Any> =\n | TriggerEntriesFromTriggers<P[\"triggers\"], P[\"identifier\"], P[\"identifier\"], P[\"authMethods\"]>\n | TriggerEntriesFromGroups<P[\"groups\"], P[\"identifier\"], P[\"identifier\"], P[\"authMethods\"]>;\n\nexport type AllTriggerEntries<Plugins extends readonly Plugin.Any[]> =\n IsAny<Plugins> extends true\n ? TriggerEntry\n : IsGenericArray<Plugins> extends true\n ? TriggerEntry\n : Plugins[number] extends infer P\n ? P extends Plugin.Any\n ? PluginTriggerEntries<P>\n : never\n : never;\n\nexport interface RuntimeTriggerEntry<\n out TriggerDef extends Trigger.Any = Trigger.Any,\n out AllowedMethods extends readonly AuthMethod.Any[] = readonly AuthMethod.Any[],\n out TriggerId extends string = string,\n out ProviderId extends string = string,\n> extends Trigger.RuntimeTriggerEntry<TriggerDef, AllowedMethods, TriggerId, ProviderId> {\n readonly localId: string;\n readonly pluginVersion: string;\n}\n\nconst entriesOf = (installation: PluginInstallation): readonly RuntimeTriggerEntry[] =>\n walkCapabilities(installation.plugin, owner => owner.triggers).map(walked => ({\n authMethods: installation.plugin.authMethods,\n localId: walked.localId,\n pluginVersion: installation.version,\n providerId: installation.plugin.identifier,\n trigger: walked.node,\n triggerId: walked.canonicalId,\n }));\n\nexport const collectTriggerEntries = (\n installations: readonly PluginInstallation[],\n): readonly RuntimeTriggerEntry[] => installations.flatMap(entriesOf);\n\nconst triggerIndex = new WeakMap<\n readonly PluginInstallation[],\n ReadonlyMap<string, RuntimeTriggerEntry>\n>();\n\n/** A trigger of the installed releases, or of the exact `version` when the caller pins one. */\nexport const resolveRuntimeTrigger = (\n installations: readonly PluginInstallation[],\n triggerId: string,\n version?: string,\n): RuntimeTriggerEntry | undefined => {\n let index = triggerIndex.get(installations);\n if (index === undefined) {\n index = new Map(collectTriggerEntries(installations).map(entry => [entry.triggerId, entry]));\n triggerIndex.set(installations, index);\n }\n const entry = index.get(triggerId);\n return entry === undefined || (version !== undefined && entry.pluginVersion !== version)\n ? undefined\n : entry;\n};\n"],"mappings":";;AA6FA,MAAM,aAAa,iBACjB,iBAAiB,aAAa,SAAQ,UAAS,MAAM,QAAQ,CAAC,CAAC,KAAI,YAAW;CAC5E,aAAa,aAAa,OAAO;CACjC,SAAS,OAAO;CAChB,eAAe,aAAa;CAC5B,YAAY,aAAa,OAAO;CAChC,SAAS,OAAO;CAChB,WAAW,OAAO;AACpB,EAAE;AAEJ,MAAa,yBACX,kBACmC,cAAc,QAAQ,SAAS;AAEpE,MAAM,+BAAe,IAAI,QAGvB;;AAGF,MAAa,yBACX,eACA,WACA,YACoC;CACpC,IAAI,QAAQ,aAAa,IAAI,aAAa;CAC1C,IAAI,UAAU,KAAA,GAAW;EACvB,QAAQ,IAAI,IAAI,sBAAsB,aAAa,CAAC,CAAC,KAAI,UAAS,CAAC,MAAM,WAAW,KAAK,CAAC,CAAC;EAC3F,aAAa,IAAI,eAAe,KAAK;CACvC;CACA,MAAM,QAAQ,MAAM,IAAI,SAAS;CACjC,OAAO,UAAU,KAAA,KAAc,YAAY,KAAA,KAAa,MAAM,kBAAkB,UAC5E,KAAA,IACA;AACN"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
//#region src/internal/handler-context.d.ts
|
|
3
|
+
export declare const handlerGroupKey: (pluginId: string) => string;
|
|
4
|
+
export declare const withoutGroups: (context: Context.Context<never>) => Context.Context<never>;
|
|
5
|
+
export declare const indexGroups: (context: Context.Context<never>) => Context.Context<never>;
|
|
6
|
+
export declare const mergeUnder: <Input>(lower: Context.Context<never>, input: Context.Context<Input>) => Context.Context<Input>;
|
|
7
|
+
export declare const findHandler: (context: Context.Context<never>, providerId: string, handlerKey: string) => unknown;
|
|
8
|
+
//#endregion
|
|
9
|
+
//# sourceMappingURL=handler-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-context.d.ts","names":[],"sources":["../../src/internal/handler-context.ts"],"mappings":";;qBAWa,kBAAe;qBAQf,gBAAa,SAAa,QAAQ,mBAAiB,QAAQ;qBAU3D,cAAW,SAAa,QAAQ,mBAAiB,QAAQ;qBASzD,aAAc,OAAK,OACvB,QAAQ,gBAAc,OACtB,QAAQ,QAAQ,WACtB,QAAQ,QAAQ;qBAKN,cAAW,SACb,QAAQ,gBAAc,oBACb"}
|