@dual-os/sdk 0.8.0-next.0 → 0.8.0-next.2
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 +5 -17
- package/dist/Action.d.ts +0 -1
- package/dist/Action.js +1 -2
- package/dist/AgentChannel.d.ts +27 -930
- package/dist/AgentChannel.d.ts.map +1 -1
- package/dist/AgentChannel.js +53 -161
- package/dist/AgentChannel.js.map +1 -1
- package/dist/AgentChannelConformance.d.ts +8 -501
- package/dist/AgentChannelConformance.d.ts.map +1 -1
- package/dist/AgentChannelConformance.js +4 -5
- package/dist/AgentChannelConformance.js.map +1 -1
- package/dist/AgentChannelRuntime.d.ts +0 -1
- package/dist/AgentChannelRuntime.d.ts.map +1 -1
- package/dist/AgentChannelRuntime.js +8 -10
- package/dist/AgentChannelRuntime.js.map +1 -1
- package/dist/AiProvider.d.ts +0 -1
- package/dist/AiProvider.js +1 -2
- package/dist/AuthMethod.d.ts +0 -1
- package/dist/AuthMethod.js +1 -2
- package/dist/AuthMethodBinding.d.ts +0 -1
- package/dist/AuthMethodBinding.js +1 -2
- package/dist/AuthMethodExecution.d.ts +0 -1
- package/dist/AuthMethodExecution.js +1 -2
- package/dist/ConnectionResolver.d.ts +0 -1
- package/dist/ConnectionResolver.js +1 -2
- package/dist/DefinitionError.d.ts +0 -1
- package/dist/DefinitionError.js +1 -2
- package/dist/DualRegistry.d.ts +0 -1
- package/dist/DualRegistry.js +1 -2
- package/dist/DualRuntime.d.ts +0 -1
- package/dist/DualRuntime.js +1 -2
- package/dist/Files.d.ts +0 -1
- package/dist/Files.js +1 -2
- package/dist/Group.d.ts +0 -1
- package/dist/Group.js +1 -2
- package/dist/Http.d.ts +0 -1
- package/dist/Http.d.ts.map +1 -1
- package/dist/Http.js +4 -5
- package/dist/Http.js.map +1 -1
- package/dist/Mcp.d.ts +0 -1
- package/dist/Mcp.js +1 -2
- package/dist/OAuth2TokenRefresher.d.ts +0 -1
- package/dist/OAuth2TokenRefresher.js +1 -2
- package/dist/OAuthFlow.d.ts +0 -1
- package/dist/OAuthFlow.js +1 -2
- package/dist/Plugin.d.ts +0 -1
- package/dist/Plugin.js +1 -2
- package/dist/PluginRuntime.d.ts +0 -1
- package/dist/PluginRuntime.js +1 -2
- package/dist/Runner.js +3 -4
- package/dist/Runner.js.map +1 -1
- package/dist/ToolFile.d.ts +0 -1
- package/dist/ToolFile.js +1 -2
- package/dist/Trigger.d.ts +0 -1
- package/dist/Trigger.js +1 -2
- package/dist/_virtual/_rolldown/runtime.js +1 -2
- package/dist/internal/auth-context.d.ts +0 -2
- package/dist/internal/auth-context.d.ts.map +1 -1
- package/dist/internal/auth-execution.d.ts +0 -2
- package/dist/internal/auth-execution.d.ts.map +1 -1
- package/dist/internal/auth-execution.js +1 -2
- package/dist/internal/auth-runtime.d.ts +0 -2
- package/dist/internal/auth-runtime.d.ts.map +1 -1
- package/dist/internal/auth-runtime.js +1 -2
- package/dist/internal/capabilities.d.ts +0 -2
- package/dist/internal/capabilities.d.ts.map +1 -1
- package/dist/internal/capabilities.js +1 -2
- package/dist/internal/children.d.ts +0 -2
- package/dist/internal/children.d.ts.map +1 -1
- package/dist/internal/children.js +1 -2
- package/dist/internal/collection-utils.d.ts +0 -2
- package/dist/internal/collection-utils.d.ts.map +1 -1
- package/dist/internal/collection-utils.js +1 -2
- package/dist/internal/dual/actions.d.ts +0 -2
- package/dist/internal/dual/actions.d.ts.map +1 -1
- package/dist/internal/dual/actions.js +1 -2
- package/dist/internal/dual/invoke.d.ts +0 -2
- package/dist/internal/dual/invoke.d.ts.map +1 -1
- package/dist/internal/dual/invoke.js +1 -2
- package/dist/internal/dual/registry.d.ts +1 -5
- package/dist/internal/dual/registry.d.ts.map +1 -1
- package/dist/internal/dual/registry.js +1 -2
- package/dist/internal/dual/registry.js.map +1 -1
- package/dist/internal/dual/triggers.d.ts +0 -2
- package/dist/internal/dual/triggers.d.ts.map +1 -1
- package/dist/internal/dual/triggers.js +1 -2
- package/dist/internal/handler-context.d.ts +0 -2
- package/dist/internal/handler-context.d.ts.map +1 -1
- package/dist/internal/handler-context.js +1 -2
- package/dist/internal/identifier.d.ts +0 -2
- package/dist/internal/identifier.d.ts.map +1 -1
- package/dist/internal/identifier.js +1 -2
- package/dist/internal/plugin-handlers.d.ts +0 -2
- package/dist/internal/plugin-handlers.d.ts.map +1 -1
- package/dist/internal/plugin-handlers.js +5 -4
- package/dist/internal/plugin-handlers.js.map +1 -1
- package/dist/internal/proto.d.ts +0 -2
- package/dist/internal/proto.d.ts.map +1 -1
- package/dist/internal/proto.js +1 -2
- package/dist/internal/schema-runtime.d.ts +0 -2
- package/dist/internal/schema-runtime.d.ts.map +1 -1
- package/dist/internal/schema-runtime.js +1 -2
- package/dist/internal/trigger-runtime-shared.d.ts +0 -2
- package/dist/internal/trigger-runtime-shared.d.ts.map +1 -1
- package/dist/internal/trigger-runtime-shared.js +1 -2
- package/dist/internal/trigger-runtime.d.ts +0 -2
- package/dist/internal/trigger-runtime.d.ts.map +1 -1
- package/dist/internal/trigger-runtime.js +1 -2
- package/dist/internal/types.d.ts +0 -2
- package/dist/internal/types.d.ts.map +1 -1
- package/dist/remote-runtime.d.ts +0 -1
- package/dist/remote-runtime.js +1 -2
- package/package.json +6 -7
- package/src/AgentChannel.ts +52 -150
- package/src/AgentChannelConformance.ts +2 -6
- package/src/AgentChannelRuntime.ts +11 -14
- package/src/Http.ts +21 -4
- package/src/Runner.ts +5 -4
- package/src/internal/dual/registry.ts +0 -2
- package/src/internal/plugin-handlers.ts +5 -2
|
@@ -2,7 +2,6 @@ import { BindingFor, Context as Context$1 } from "../AuthMethodBinding.js";
|
|
|
2
2
|
import { Any, MaterialSchema, Requirements, SetupSchema, ValueSchema } from "../AuthMethod.js";
|
|
3
3
|
import { ConnectionIdNotAllowedError, ConnectionReauthorizationRequiredError, ConnectionRequiredError, ConnectionResolutionContext, ConnectionResolverStoreError, ConnectionSelectionRequiredError, ConnectionTargetKind, InvalidConnectionIdError, InvalidResolvedConnectionError, Service } from "../ConnectionResolver.js";
|
|
4
4
|
import { Effect, Schema } from "effect";
|
|
5
|
-
//#region src/internal/auth-execution.d.ts
|
|
6
5
|
export type NonEmptyReadonlyArray<A> = readonly [A, ...A[]];
|
|
7
6
|
export type AuthSchemaRequirements<Methods extends readonly Any[]> = Methods[number] extends (infer Method) ? Method extends Any ? Schema.Codec.DecodingServices<ValueSchema<Method>> : never : never;
|
|
8
7
|
/**
|
|
@@ -23,5 +22,4 @@ export declare const authRuntimeContext: <Methods extends readonly Any[]>(bindin
|
|
|
23
22
|
export declare const toNonEmptyArray: <A>(values: readonly A[]) => NonEmptyReadonlyArray<A> | undefined;
|
|
24
23
|
export declare const failConnectionIdNotAllowed: (targetKind: ConnectionTargetKind, targetId: string, phase: string | undefined, providerId: string, connectionId: string) => Effect.Effect<never, ConnectionIdNotAllowedError>;
|
|
25
24
|
export declare const resolveRuntimeConnection: <Methods extends NonEmptyReadonlyArray<Any>>(targetKind: ConnectionTargetKind, targetId: string, phase: string | undefined, providerId: string, methods: Methods, connectionId: string | undefined, context: ConnectionResolutionContext | undefined) => Effect.Effect<BindingFor<Methods>, ConnectionRequiredError | ConnectionSelectionRequiredError | InvalidConnectionIdError | InvalidResolvedConnectionError | ConnectionReauthorizationRequiredError | ConnectionResolverStoreError, Service | AuthSchemaRequirements<Methods> | AuthResolutionRequirements<Methods>>;
|
|
26
|
-
//#endregion
|
|
27
25
|
//# sourceMappingURL=auth-execution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-execution.d.ts","names":["AuthMethod.Any","AuthMethod.ValueSchema","AuthMethod.SetupSchema","AuthMethod.MaterialSchema","AuthMethod.Requirements","AuthMethodBinding.BindingFor","AuthMethodBinding.Context","ConnectionResolver.Service"],"sources":["../../src/internal/auth-execution.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth-execution.d.ts","names":["AuthMethod.Any","AuthMethod.ValueSchema","AuthMethod.SetupSchema","AuthMethod.MaterialSchema","AuthMethod.Requirements","AuthMethodBinding.BindingFor","AuthMethodBinding.Context","ConnectionResolver.Service"],"sources":["../../src/internal/auth-execution.ts"],"mappings":";;;;YAqBY,sBAAsB,eAAe,MAAM;YAE3C,uBAAuB,yBAAyBA,SAC1D,+BAA8B,UAC1B,eAAeA,MACb,OAAO,MAAM,iBAAiBC,YAAuB;;;;;;;;;;YAajD,2BAA2B,yBAAyBD,SAC9D,+BAA8B,UAC1B,eAAeA,OAERE,YAAuB,gBAAgB,OAAO,MAC3C,OAAO,MAAM,iBAAiBA,YAAuB,oBAEzD,OAAO,MAAM,iBAAiBC,eAA0B,WACxD,OAAO,MAAM,iBAAiBF,YAAuB,WACrDG,aAAwB;YAIxB,2BAA2B,yBAAyBJ,SAC5D,gCACE,2CAGM,0BACA,mCACA,2BACA,iCACA,yCACA;qBA0DC,4BAA2B;qBAE3B,qBAAsB,yBAAyBA,OAAgB,SACjEK,WAA6B;WAC1B,MAAMC,UAA0B;;qBAEjC,kBAAmB,GAAC,iBAAmB,QAAM,sBAAsB;qBAGnE,6BAA0B,YACzB,sBAAoB,kBAChB,2BACS,oBACP,yBAEjB,OAAO,cAAc;qBAKX,2BAA2B,gBAAgB,sBAAsBN,MAC5E,YAAY,sBACZ,kBACA,2BACA,oBACA,SAAS,SACT,kCACA,SAAS,4CACN,OAAO,OACVK,WAA6B,UAC3B,0BACA,mCACA,2BACA,iCACA,yCACA,8BACFE,UAA6B,uBAAuB,WAAW,2BAA2B"}
|
|
@@ -3,7 +3,7 @@ import { decodeSetup, resolveDecoded, resolveUnknown } from "../AuthMethodExecut
|
|
|
3
3
|
import { ConnectionIdNotAllowedError, InvalidResolvedConnectionError, Service } from "../ConnectionResolver.js";
|
|
4
4
|
import { decodeJson } from "./schema-runtime.js";
|
|
5
5
|
import { Effect } from "effect";
|
|
6
|
-
|
|
6
|
+
// src/internal/auth-execution.ts
|
|
7
7
|
const knownAuthMethodIds = (methods) => methods.map((method) => method.identifier);
|
|
8
8
|
const fullAuthMethodId = (providerId, method) => `${providerId}/${method.identifier}`;
|
|
9
9
|
const findMethod = (providerId, methods, methodId) => methods.find((method) => method.identifier === methodId || fullAuthMethodId(providerId, method) === methodId);
|
|
@@ -60,7 +60,6 @@ const resolveRuntimeConnection = (targetKind, targetId, phase, providerId, metho
|
|
|
60
60
|
value
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
|
-
//#endregion
|
|
64
63
|
export { authRuntimeContext, failConnectionIdNotAllowed, noAuthRuntimeContext, resolveRuntimeConnection, toNonEmptyArray };
|
|
65
64
|
|
|
66
65
|
//# sourceMappingURL=auth-execution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-runtime.d.ts","names":["AuthMethod.Any"],"sources":["../../src/internal/auth-runtime.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth-runtime.d.ts","names":["AuthMethod.Any"],"sources":["../../src/internal/auth-runtime.ts"],"mappings":";qBAGa,yCAAsC,4BACvB,kBACRA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DuplicateAuthMethodIdentifierError } from "../DefinitionError.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/auth-runtime.ts
|
|
3
3
|
const assertNoDuplicateAuthMethodIdentifiers = (providerIdentifier, methods) => {
|
|
4
4
|
const seen = /* @__PURE__ */ new Set();
|
|
5
5
|
for (const method of methods) {
|
|
@@ -10,7 +10,6 @@ const assertNoDuplicateAuthMethodIdentifiers = (providerIdentifier, methods) =>
|
|
|
10
10
|
seen.add(method.identifier);
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
//#endregion
|
|
14
13
|
export { assertNoDuplicateAuthMethodIdentifiers };
|
|
15
14
|
|
|
16
15
|
//# sourceMappingURL=auth-runtime.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Any } from "../Action.js";
|
|
2
2
|
import { Any as Any$1 } from "../Trigger.js";
|
|
3
3
|
import { Any as Any$2 } from "../Group.js";
|
|
4
|
-
//#region src/internal/capabilities.d.ts
|
|
5
4
|
type StructuralOwner = {
|
|
6
5
|
readonly groups: readonly Any$2[];
|
|
7
6
|
readonly actions: readonly Any[];
|
|
@@ -19,6 +18,5 @@ export declare const walkCapabilities: <Node extends {
|
|
|
19
18
|
}>(provider: StructuralOwner & {
|
|
20
19
|
readonly identifier: string;
|
|
21
20
|
}, select: (owner: StructuralOwner) => readonly Node[]) => readonly WalkedCapability<Node>[];
|
|
22
|
-
//#endregion
|
|
23
21
|
export {};
|
|
24
22
|
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","names":["Group.Any","Action.Any","Trigger.Any"],"sources":["../../src/internal/capabilities.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","names":["Group.Any","Action.Any","Trigger.Any"],"sources":["../../src/internal/capabilities.ts"],"mappings":";;;KAaK;WACM,iBAAiBA;WACjB,kBAAkBC;WAClB,mBAAmBC;;YAGlB,iBAAiB;;WAElB;;WAEA;WACA,MAAM;;qBAGJ,mBAAoB;WAAwB;GAAoB,UACjE;WAA6B;GAAoB,SAClD,OAAO,6BAA6B,oBACnC,iBAAiB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./identifier.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/capabilities.ts
|
|
3
3
|
const walkCapabilities = (provider, select) => {
|
|
4
4
|
const entries = [];
|
|
5
5
|
const visit = (owner, prefix) => {
|
|
@@ -16,7 +16,6 @@ const walkCapabilities = (provider, select) => {
|
|
|
16
16
|
visit(provider, "");
|
|
17
17
|
return entries;
|
|
18
18
|
};
|
|
19
|
-
//#endregion
|
|
20
19
|
export { walkCapabilities };
|
|
21
20
|
|
|
22
21
|
//# sourceMappingURL=capabilities.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Any } from "../Action.js";
|
|
2
2
|
import { Any as Any$1 } from "../Trigger.js";
|
|
3
3
|
import { Any as Any$2 } from "../Group.js";
|
|
4
|
-
//#region src/internal/children.d.ts
|
|
5
4
|
export type StructuralChild = Any$2 | Any | Any$1;
|
|
6
5
|
export type StructuralChildKind = "group" | "action" | "trigger" | "agent-channel";
|
|
7
6
|
/**
|
|
@@ -29,6 +28,5 @@ export declare const assertUniqueStructuralChildIdentifiers: (ownerKind: "group"
|
|
|
29
28
|
* so a collision between two added children of different kinds is still caught.
|
|
30
29
|
*/
|
|
31
30
|
export declare const assertUniqueMixedChildIdentifiers: (ownerKind: "group" | "plugin", ownerIdentifier: string, existing: ExistingChildren, additions: readonly StructuralChild[]) => void;
|
|
32
|
-
//#endregion
|
|
33
31
|
export {};
|
|
34
32
|
//# sourceMappingURL=children.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"children.d.ts","names":["Group.Any","Action.Any","Trigger.Any"],"sources":["../../src/internal/children.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"children.d.ts","names":["Group.Any","Action.Any","Trigger.Any"],"sources":["../../src/internal/children.ts"],"mappings":";;;YAYY,kBAAkBA,QAAYC,MAAaC;YAE3C;;;;YAKA,eACV,0BAA0B,mBAC1B,UACE,iCAAiC,eAAe,sBAAsB,qBACtE,aAAa,mBACD,SAAS,eAAe,MAAM,WACxC,eAAe,MAAM;YAGf;WACD,iBAAiBF;WACjB,kBAAkBC;WAClB,mBAAmBC;;qBAGjB,oBAAiB,mBAAuB,sBAAoB;KASpE;WAA6B;;KAE7B;WACM,iBAAiB;WACjB,kBAAkB;WAClB,mBAAmB;WACnB,yBAAyB;;qBA6CvB,yCAAsC,+BACpB,yBACN,UACb,kBAAgB,oBACN,mBAAiB,WAC1B;;;;;qBAcA,oCAAiC,+BACf,yBACN,UACb,kBAAgB,oBACN"}
|
|
@@ -2,7 +2,7 @@ import { BuilderCollisionError } from "../DefinitionError.js";
|
|
|
2
2
|
import { isAction } from "../Action.js";
|
|
3
3
|
import { isTrigger } from "../Trigger.js";
|
|
4
4
|
import { isGroup } from "../Group.js";
|
|
5
|
-
|
|
5
|
+
// src/internal/children.ts
|
|
6
6
|
/**
|
|
7
7
|
* Shared structural-children machinery for Group and Plugin builders.
|
|
8
8
|
*
|
|
@@ -47,7 +47,6 @@ const assertUniqueStructuralChildIdentifiers = (ownerKind, ownerIdentifier, exis
|
|
|
47
47
|
const assertUniqueMixedChildIdentifiers = (ownerKind, ownerIdentifier, existing, additions) => {
|
|
48
48
|
assertAdditions(ownerKind, ownerIdentifier, seenChildren(existing), additions.map((addition) => [addition, childKind(addition)]));
|
|
49
49
|
};
|
|
50
|
-
//#endregion
|
|
51
50
|
export { assertUniqueMixedChildIdentifiers, assertUniqueStructuralChildIdentifiers, partitionChildren };
|
|
52
51
|
|
|
53
52
|
//# sourceMappingURL=children.js.map
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
//#region src/internal/collection-utils.d.ts
|
|
2
1
|
export declare const appendElements: <Existing extends readonly unknown[], Added extends readonly unknown[]>(existing: Existing, additions: Added) => readonly [...Existing, ...Added];
|
|
3
|
-
//#endregion
|
|
4
2
|
//# sourceMappingURL=collection-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-utils.d.ts","names":[],"sources":["../../src/internal/collection-utils.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"collection-utils.d.ts","names":[],"sources":["../../src/internal/collection-utils.ts"],"mappings":"A,qBAAa,iBACX,qCACA,kCAAgC,UAEtB,UAAQ,WACP,uBACG,aAAa"}
|
|
@@ -5,7 +5,6 @@ import { MachineIdSeparator } from "../identifier.js";
|
|
|
5
5
|
import { IsAny, IsGenericArray } from "../types.js";
|
|
6
6
|
import { Any as Any$3 } from "../../Plugin.js";
|
|
7
7
|
import { PluginInstallation } from "../../DualRuntime.js";
|
|
8
|
-
//#region src/internal/dual/actions.d.ts
|
|
9
8
|
interface ActionEntry<Id extends string = string, ActionDef extends Any$1 = Any$1> {
|
|
10
9
|
readonly actionId: Id;
|
|
11
10
|
readonly action: ActionDef;
|
|
@@ -28,6 +27,5 @@ export interface RuntimeActionEntry<out ActionId extends string = string, out Pr
|
|
|
28
27
|
export declare const collectActionEntries: (installations: readonly PluginInstallation[]) => readonly RuntimeActionEntry[];
|
|
29
28
|
/** An action of the installed releases, or of the exact `version` when the caller pins one. */
|
|
30
29
|
export declare const resolveAction: (installations: readonly PluginInstallation[], actionId: string, version?: string) => RuntimeActionEntry | undefined;
|
|
31
|
-
//#endregion
|
|
32
30
|
export {};
|
|
33
31
|
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","names":["Action.Any","Group.Any","Plugin.Any","AuthMethod.Any"],"sources":["../../../src/internal/dual/actions.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"actions.d.ts","names":["Action.Any","Group.Any","Plugin.Any","AuthMethod.Any"],"sources":["../../../src/internal/dual/actions.ts"],"mappings":";;;;;;;UASU,YAAY,4BAA4B,kBAAkBA,QAAaA;WACtE,UAAU;WACV,QAAQ;;KAGd,yBAAyB,yBAAyBA,SAAc,yBACnE,eAAe,wBACX,cACA,+BAA8B,aAC5B,kBAAkBA,QAChB,eAAe,gBAAgB,qBAAqB,2BAA2B;KAIpF,wBAAwB,wBAAwBC,SAAa,yBAChE,eAAe,uBACX,cACA,8BAA6B,YAC3B,iBAAiBA,QACf,mBACE,aACG,gBAAgB,qBAAqB;KAK/C,mBAAmB,iBAAiBA,OAAW,yBAChD,yBAAyB,qBAAqB,UAC9C,wBAAwB,oBAAoB;YAEpC,oBAAoB,UAAUC,SACtC,yBAAyB,cAAc,mBACvC,wBAAwB,aAAa;YAE7B,iBAAiB,yBAAyBA,WACpD,MAAM,wBACF,cACA,eAAe,wBACb,cACA,+BAA8B,KAC5B,UAAUA,QACR,oBAAoB;KAI3B,aAAa,wBAAwBD,WACxC,eAAe,uBACXD,QACA,8BAA6B,YAC3B,iBAAiBC,QACf,8BAA8B,aAAa;YAIzC,cAAc,UAAUC,SAAc,uBAAuB,aAAa;iBAErE,uBACX,sCACA,wCACA,kBAAkBF,QAAaA,WAC/B,gCAAgCG,iBAA4BA;WAEvD,UAAU;WACV,YAAY;WACZ;WACA;WACA,QAAQ;WACR,aAAa;;qBAeX,uBAAoB,wBACP,kCACd;;qBAQC,gBAAa,wBACA,sBAAoB,kBAC5B,qBAEf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { walkCapabilities } from "../capabilities.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/dual/actions.ts
|
|
3
3
|
const entriesOf = (installation) => walkCapabilities(installation.plugin, (owner) => owner.actions).map(({ localId, canonicalId, node }) => ({
|
|
4
4
|
action: node,
|
|
5
5
|
actionId: canonicalId,
|
|
@@ -20,7 +20,6 @@ const resolveAction = (installations, actionId, version) => {
|
|
|
20
20
|
const entry = index.get(actionId);
|
|
21
21
|
return entry === void 0 || version !== void 0 && entry.pluginVersion !== version ? void 0 : entry;
|
|
22
22
|
};
|
|
23
|
-
//#endregion
|
|
24
23
|
export { collectActionEntries, resolveAction };
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=actions.js.map
|
|
@@ -6,7 +6,6 @@ import { ActionHandlerServiceOf } from "../plugin-handlers.js";
|
|
|
6
6
|
import { Any as Any$2 } from "../../Plugin.js";
|
|
7
7
|
import { PluginActionEntries } from "./actions.js";
|
|
8
8
|
import { Effect, Schema } from "effect";
|
|
9
|
-
//#region src/internal/dual/invoke.d.ts
|
|
10
9
|
export interface InvokeRequest {
|
|
11
10
|
readonly actionId: string;
|
|
12
11
|
/** The exact plugin release the caller pinned; another installed release does not run. */
|
|
@@ -58,6 +57,5 @@ export type InvokeRequirementsFor<Plugins extends readonly Any$2[], ActionId ext
|
|
|
58
57
|
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
58
|
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
59
|
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
60
|
export {};
|
|
63
61
|
//# sourceMappingURL=invoke.d.ts.map
|
|
@@ -1 +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":"
|
|
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"}
|
|
@@ -3,7 +3,7 @@ import { findHandler, mergeUnder } from "../handler-context.js";
|
|
|
3
3
|
import { decodeJsonMapError } from "../schema-runtime.js";
|
|
4
4
|
import { authRuntimeContext, failConnectionIdNotAllowed, noAuthRuntimeContext, resolveRuntimeConnection, toNonEmptyArray } from "../auth-execution.js";
|
|
5
5
|
import { Effect, Schema, SchemaIssue } from "effect";
|
|
6
|
-
|
|
6
|
+
// src/internal/dual/invoke.ts
|
|
7
7
|
var FieldIssue = class extends Schema.Class("FieldIssue")({
|
|
8
8
|
message: Schema.String,
|
|
9
9
|
path: Schema.String
|
|
@@ -69,7 +69,6 @@ const invokeResolvedActionJson = (providerId, actionId, pluginVersion, action, a
|
|
|
69
69
|
description: error.message,
|
|
70
70
|
fields: schemaErrorFields(error)
|
|
71
71
|
}))));
|
|
72
|
-
//#endregion
|
|
73
72
|
export { ActionHandlerNotFoundError, ActionNotFoundError, FieldIssue, InvalidActionInputError, InvalidActionOutputError, invokeResolvedAction, invokeResolvedActionJson };
|
|
74
73
|
|
|
75
74
|
//# sourceMappingURL=invoke.js.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { AuthMethodKind } from "../../AuthMethod.js";
|
|
2
|
-
import { Exposure, Features,
|
|
2
|
+
import { Exposure, Features, RequiredChecks } from "../../AgentChannel.js";
|
|
3
3
|
import { Category } from "../../Plugin.js";
|
|
4
4
|
import { Any } from "../../AiProvider.js";
|
|
5
5
|
import { PluginInstallation } from "../../DualRuntime.js";
|
|
6
6
|
import { Schema } from "effect";
|
|
7
|
-
//#region src/internal/dual/registry.d.ts
|
|
8
7
|
export interface MaterializedRegistryOptions {
|
|
9
8
|
readonly schemaJson?: ((schema: Schema.Top) => unknown) | undefined;
|
|
10
9
|
readonly projections?: Map<Schema.Top, unknown> | undefined;
|
|
@@ -96,8 +95,6 @@ export interface MaterializedChannelCapabilityVersion {
|
|
|
96
95
|
readonly extensionsSchemaJson: Readonly<Record<string, unknown>>;
|
|
97
96
|
readonly featuresJson: Features;
|
|
98
97
|
readonly exposure: typeof Exposure.Type;
|
|
99
|
-
/** Absent for the original protocol. */
|
|
100
|
-
readonly protocol?: Protocol;
|
|
101
98
|
readonly requiredChecks: typeof RequiredChecks.Type;
|
|
102
99
|
}
|
|
103
100
|
export type MaterializedCapabilityVersion = MaterializedChannelCapabilityVersion | MaterializedActionCapabilityVersion | MaterializedTriggerCapabilityVersion;
|
|
@@ -121,5 +118,4 @@ export declare const materializeResolvedRegistry: (input: {
|
|
|
121
118
|
readonly projections?: Map<Schema.Top, unknown> | undefined;
|
|
122
119
|
readonly projectSchemas?: ((capabilityId: string, version: string) => boolean) | undefined;
|
|
123
120
|
}) => MaterializedRegistry;
|
|
124
|
-
//#endregion
|
|
125
121
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","names":["AuthMethod.AuthMethodKind","Plugin.Category","AgentChannel.Features","
|
|
1
|
+
{"version":3,"file":"registry.d.ts","names":["AuthMethod.AuthMethodKind","Plugin.Category","AgentChannel.Features","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;WACvC,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"}
|
|
@@ -3,7 +3,7 @@ import { registryId } from "../../AiProvider.js";
|
|
|
3
3
|
import { collectActionEntries } from "./actions.js";
|
|
4
4
|
import { collectTriggerEntries } from "./triggers.js";
|
|
5
5
|
import { Schema } from "effect";
|
|
6
|
-
|
|
6
|
+
// src/internal/dual/registry.ts
|
|
7
7
|
/** Materialized Dual registry DTOs and resolver. */
|
|
8
8
|
const authMethodId = (providerId, methodId) => `${providerId}/${methodId}`;
|
|
9
9
|
const schemaJson = (schema) => Schema.toJsonSchemaDocument(schema, { onExcessProperty: "error" });
|
|
@@ -166,7 +166,6 @@ const materializeResolvedRegistry = (input) => {
|
|
|
166
166
|
providers: [...toolProviders, ...aiProviders]
|
|
167
167
|
};
|
|
168
168
|
};
|
|
169
|
-
//#endregion
|
|
170
169
|
export { materializeResolvedRegistry };
|
|
171
170
|
|
|
172
171
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +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;CACtE,MAAM,WAAW,eAAe,OAAO,OAAO,QAAQ;CAEtD,OAAO,EACL,QAAQ;EACN,QAAQ,OAAO,OAAO;EACtB,GAAI,iBAAiB,KAAA,IACjB,CAAC,IACD,EAAE,sBAAsB,aAAa,kBAAkB,QAAQ;EACnE,GAAI,iBAAiB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa;EACrD,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,iBAAiB;EAC7D,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS;EAC7C,GAAI,OAAO,OAAO,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,OAAO,OAAO,KAAK;EACvE,GAAI,OAAO,OAAO,wBAAwB,KAAA,IACtC,CAAC,IACD,EAAE,qBAAqB,OAAO,OAAO,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ED,OAAO;EAAE,gBAAgB,MAAM;EAAgB,WAAW,CAAC,GAAG,eAAe,GAAG,WAAW;CAAE;AAC/F"}
|
|
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 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":";;;;;;;AAyHA,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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,aAAa,OAAO;IACpB,IAAI,aAAa,IAAI,OAAO,UAAU;IACtC,iBAAiB,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"}
|
|
@@ -5,7 +5,6 @@ import { MachineIdSeparator } from "../identifier.js";
|
|
|
5
5
|
import { IsAny, IsGenericArray } from "../types.js";
|
|
6
6
|
import { Any as Any$3 } from "../../Plugin.js";
|
|
7
7
|
import { PluginInstallation } from "../../DualRuntime.js";
|
|
8
|
-
//#region src/internal/dual/triggers.d.ts
|
|
9
8
|
export interface TriggerEntry<Id extends string = string, ProviderId extends string = string, TriggerDef extends Any$1 = Any$1, AllowedMethods extends readonly Any[] = readonly Any[]> {
|
|
10
9
|
readonly triggerId: Id;
|
|
11
10
|
readonly providerId: ProviderId;
|
|
@@ -24,6 +23,5 @@ export interface RuntimeTriggerEntry<out TriggerDef extends Any$1 = Any$1, out A
|
|
|
24
23
|
export declare const collectTriggerEntries: (installations: readonly PluginInstallation[]) => readonly RuntimeTriggerEntry[];
|
|
25
24
|
/** A trigger of the installed releases, or of the exact `version` when the caller pins one. */
|
|
26
25
|
export declare const resolveRuntimeTrigger: (installations: readonly PluginInstallation[], triggerId: string, version?: string) => RuntimeTriggerEntry | undefined;
|
|
27
|
-
//#endregion
|
|
28
26
|
export {};
|
|
29
27
|
//# sourceMappingURL=triggers.d.ts.map
|
|
@@ -1 +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":"
|
|
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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { walkCapabilities } from "../capabilities.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/dual/triggers.ts
|
|
3
3
|
const entriesOf = (installation) => walkCapabilities(installation.plugin, (owner) => owner.triggers).map((walked) => ({
|
|
4
4
|
authMethods: installation.plugin.authMethods,
|
|
5
5
|
localId: walked.localId,
|
|
@@ -20,7 +20,6 @@ const resolveRuntimeTrigger = (installations, triggerId, version) => {
|
|
|
20
20
|
const entry = index.get(triggerId);
|
|
21
21
|
return entry === void 0 || version !== void 0 && entry.pluginVersion !== version ? void 0 : entry;
|
|
22
22
|
};
|
|
23
|
-
//#endregion
|
|
24
23
|
export { collectTriggerEntries, resolveRuntimeTrigger };
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=triggers.js.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Context } from "effect";
|
|
2
|
-
//#region src/internal/handler-context.d.ts
|
|
3
2
|
export declare const handlerGroupKey: (pluginId: string) => string;
|
|
4
3
|
export declare const withoutGroups: (context: Context.Context<never>) => Context.Context<never>;
|
|
5
4
|
export declare const indexGroups: (context: Context.Context<never>) => Context.Context<never>;
|
|
6
5
|
export declare const mergeUnder: <Input>(lower: Context.Context<never>, input: Context.Context<Input>) => Context.Context<Input>;
|
|
7
6
|
export declare const findHandler: (context: Context.Context<never>, providerId: string, handlerKey: string) => unknown;
|
|
8
|
-
//#endregion
|
|
9
7
|
//# sourceMappingURL=handler-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler-context.d.ts","names":[],"sources":["../../src/internal/handler-context.ts"],"mappings":"
|
|
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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Array, Context, Predicate, String } from "effect";
|
|
2
|
-
|
|
2
|
+
// src/internal/handler-context.ts
|
|
3
3
|
/**
|
|
4
4
|
* A plugin's handlers live in the layer context as one group entry, keyed by
|
|
5
5
|
* plugin id, so merging layer outputs grows with the number of plugins and
|
|
@@ -25,7 +25,6 @@ const findHandler = (context, providerId, handlerKey) => {
|
|
|
25
25
|
const group = context.mapUnsafe.get(groupKey) ?? Context.getOrUndefined(context, HandlerIndex)?.get(groupKey);
|
|
26
26
|
return Predicate.isMap(group) ? group.get(handlerKey) : void 0;
|
|
27
27
|
};
|
|
28
|
-
//#endregion
|
|
29
28
|
export { findHandler, handlerGroupKey, indexGroups, mergeUnder, withoutGroups };
|
|
30
29
|
|
|
31
30
|
//# sourceMappingURL=handler-context.js.map
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { DefinitionIdentifierKind } from "../DefinitionError.js";
|
|
2
|
-
//#region src/internal/identifier.d.ts
|
|
3
2
|
export declare const MachineIdSeparator: "/";
|
|
4
3
|
export declare const validateIdentifier: (kind: DefinitionIdentifierKind, identifier: string) => void;
|
|
5
|
-
//#endregion
|
|
6
4
|
//# sourceMappingURL=identifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifier.d.ts","names":[],"sources":["../../src/internal/identifier.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"identifier.d.ts","names":[],"sources":["../../src/internal/identifier.ts"],"mappings":";qBAIa;qBAKA,qBAAkB,MAAU,0BAAwB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InvalidIdentifierError } from "../DefinitionError.js";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
|
-
|
|
3
|
+
// src/internal/identifier.ts
|
|
4
4
|
const MachineIdSeparator = "/";
|
|
5
5
|
const identifierSchema = Schema.String.check(Schema.isPattern(/^[a-z0-9]+(?:-[a-z0-9]+)*$/));
|
|
6
6
|
const isIdentifier = Schema.is(identifierSchema);
|
|
@@ -22,7 +22,6 @@ const validateIdentifier = (kind, identifier) => {
|
|
|
22
22
|
reason: "invalid-format"
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
|
-
//#endregion
|
|
26
25
|
export { MachineIdSeparator, validateIdentifier };
|
|
27
26
|
|
|
28
27
|
//# sourceMappingURL=identifier.js.map
|
|
@@ -6,7 +6,6 @@ import { MachineIdSeparator } from "./identifier.js";
|
|
|
6
6
|
import { IsGenericArray, JoinPrefix } from "./types.js";
|
|
7
7
|
import { Any as Any$3 } from "../Plugin.js";
|
|
8
8
|
import { Context, Effect } from "effect";
|
|
9
|
-
//#region src/internal/plugin-handlers.d.ts
|
|
10
9
|
type LocalTriggerEntriesFromTriggers<Triggers extends readonly Any$1[], Prefix extends string, AllowedMethods extends readonly Any[]> = Triggers[number] extends (infer TriggerDef) ? TriggerDef extends Any$1 ? {
|
|
11
10
|
readonly localId: JoinPrefix<Prefix, TriggerDef["identifier"]>;
|
|
12
11
|
readonly trigger: TriggerDef;
|
|
@@ -33,6 +32,5 @@ interface Declarations {
|
|
|
33
32
|
}
|
|
34
33
|
/** Register a plugin's handlers as one Context group keyed by the plugin. */
|
|
35
34
|
export declare const toHandlers: (plugin: Any$3, handlers: Declarations) => Effect.Effect<Context.Context<never>>;
|
|
36
|
-
//#endregion
|
|
37
35
|
export {};
|
|
38
36
|
//# sourceMappingURL=plugin-handlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-handlers.d.ts","names":["Trigger.Any","AuthMethod.Any","Group.Any","Any","AgentChannel.Handler","Trigger.Handler"],"sources":["../../src/internal/plugin-handlers.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-handlers.d.ts","names":["Trigger.Any","AuthMethod.Any","Group.Any","Any","AgentChannel.Handler","Trigger.Handler"],"sources":["../../src/internal/plugin-handlers.ts"],"mappings":";;;;;;;;KAeK,gCACH,0BAA0BA,SAC1B,uBACA,gCAAgCC,SAC9B,gCAA+B,cAC/B,mBAAmBD;WAEN,SAAS,WAAW,QAAQ;WAC5B,SAAS;WACT,aAAa;;KAKzB,8BACH,iBAAiBE,OACjB,uBACA,gCAAgCD,SAC9B,2BAEI,gCACE,sBACA,WAAW,QAAQ,yBACnB,mBAED,eAAe,mCACZ,yCAAyCD,iBAAuB,kBAChE,8BACE,4BACA,WAAW,QAAQ,yBACnB;YAIF,oBAAoB,UAAUG,SACtC,gCAAgC,mBAAmB,oBACnD,8BAA8B,yBAAyB;YAE/C,mBACV,UAAUA,OACV,6BACK,yBAAyB,qBAAqB;;iBAGpC,4BACR,gCACA,2CACA;WAEE;WACA,UAAU;WACV,SAAS;WACT,QAAQ;;YAGP,uBAAuB,UAAUA,SAAO,qBAClD,iBACA,cACA;YAGU,gBAAgB,UAAUA,SAClC,uBAAuB,OACrB,sDAEEC,WAAwB,mBAAmB,gDAC9C,oBAAoB,kBAAiB,SAClC;WAAyB,eAAe;IACtCC,UAAgB,mBAAmB,GAAG;UAItC;WACC;WACA;WACA;;;qBAmBE,aAAU,QACbF,OAAG,UACD,iBACT,OAAO,OAAO,QAAQ"}
|
|
@@ -5,7 +5,7 @@ import { handlerGroupKey, withoutGroups } from "./handler-context.js";
|
|
|
5
5
|
import { walkCapabilities } from "./capabilities.js";
|
|
6
6
|
import { handlerKey as handlerKey$2 } from "../Trigger.js";
|
|
7
7
|
import { Context, Effect, Predicate } from "effect";
|
|
8
|
-
|
|
8
|
+
// src/internal/plugin-handlers.ts
|
|
9
9
|
/** Plugin handler services and their registration. */
|
|
10
10
|
const missingDeclaration = (kind, localId, pluginId) => {
|
|
11
11
|
throw new Error(`missing ${kind} handler for "${localId}" in plugin "${pluginId}"`);
|
|
@@ -20,8 +20,10 @@ const getNestedHandler = (handlers, localId) => {
|
|
|
20
20
|
};
|
|
21
21
|
/** Register a plugin's handlers as one Context group keyed by the plugin. */
|
|
22
22
|
const toHandlers = (plugin, handlers) => Effect.gen(function* () {
|
|
23
|
-
const
|
|
24
|
-
const
|
|
23
|
+
const context = yield* Effect.context();
|
|
24
|
+
const services = withoutGroups(context);
|
|
25
|
+
const inherited = context.mapUnsafe.get(handlerGroupKey(plugin.identifier));
|
|
26
|
+
const map = new Map(Predicate.isMap(inherited) ? inherited : []);
|
|
25
27
|
const find = (kind, declarations, localId) => {
|
|
26
28
|
const handler = getNestedHandler(declarations, localId);
|
|
27
29
|
return handler === void 0 ? missingDeclaration(kind, localId, plugin.identifier) : handler;
|
|
@@ -46,7 +48,6 @@ const toHandlers = (plugin, handlers) => Effect.gen(function* () {
|
|
|
46
48
|
}
|
|
47
49
|
return Context.makeUnsafe(/* @__PURE__ */ new Map([[handlerGroupKey(plugin.identifier), map]]));
|
|
48
50
|
});
|
|
49
|
-
//#endregion
|
|
50
51
|
export { toHandlers };
|
|
51
52
|
|
|
52
53
|
//# sourceMappingURL=plugin-handlers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-handlers.js","names":["Action.handlerKey","Trigger.handlerKey","AgentChannel.handlerKey"],"sources":["../../src/internal/plugin-handlers.ts"],"sourcesContent":["/** Plugin handler services and their registration. */\nimport { Context, Effect, Predicate } from \"effect\";\n\nimport * as Action from \"../Action.ts\";\nimport * as AgentChannel from \"../AgentChannel.ts\";\nimport type * as AuthMethod from \"../AuthMethod.ts\";\nimport type * as Group from \"../Group.ts\";\nimport type { Any } from \"../Plugin.ts\";\nimport * as Trigger from \"../Trigger.ts\";\n\nimport { walkCapabilities } from \"./capabilities.ts\";\nimport { handlerGroupKey, withoutGroups } from \"./handler-context.ts\";\nimport { MachineIdSeparator } from \"./identifier.ts\";\nimport type { IsGenericArray, JoinPrefix } from \"./types.ts\";\n\ntype LocalTriggerEntriesFromTriggers<\n Triggers extends readonly Trigger.Any[],\n Prefix extends string,\n AllowedMethods extends readonly AuthMethod.Any[],\n> = Triggers[number] extends infer TriggerDef\n ? TriggerDef extends Trigger.Any\n ? {\n readonly localId: JoinPrefix<Prefix, TriggerDef[\"identifier\"]>;\n readonly trigger: TriggerDef;\n readonly authMethods: AllowedMethods;\n }\n : never\n : never;\n\ntype LocalTriggerEntriesFromGroups<\n GroupDef extends Group.Any,\n Prefix extends string,\n AllowedMethods extends readonly AuthMethod.Any[],\n> = GroupDef extends unknown\n ?\n | LocalTriggerEntriesFromTriggers<\n GroupDef[\"triggers\"],\n JoinPrefix<Prefix, GroupDef[\"identifier\"]>,\n AllowedMethods\n >\n | (IsGenericArray<GroupDef[\"groups\"]> extends true\n ? LocalTriggerEntriesFromTriggers<readonly Trigger.Any[], string, AllowedMethods>\n : LocalTriggerEntriesFromGroups<\n GroupDef[\"groups\"][number],\n JoinPrefix<Prefix, GroupDef[\"identifier\"]>,\n AllowedMethods\n >)\n : never;\n\nexport type LocalTriggerEntries<P extends Any> =\n | LocalTriggerEntriesFromTriggers<P[\"triggers\"], \"\", P[\"authMethods\"]>\n | LocalTriggerEntriesFromGroups<P[\"groups\"][number], \"\", P[\"authMethods\"]>;\n\nexport type CanonicalTriggerId<\n P extends Any,\n LocalId extends string,\n> = `${P[\"identifier\"]}${typeof MachineIdSeparator}${LocalId}`;\n\n/** Keyed by the plugin's capabilities, which `Plugin.provide` keeps, so a Layer serves only them. */\nexport interface ActionHandlerService<\n in out PluginId extends string,\n in out Actions extends readonly unknown[],\n in out Groups extends readonly unknown[],\n> {\n readonly _: unique symbol;\n readonly pluginId: PluginId;\n readonly actions: Actions;\n readonly groups: Groups;\n}\n\nexport type ActionHandlerServiceOf<P extends Any> = ActionHandlerService<\n P[\"identifier\"],\n P[\"actions\"],\n P[\"groups\"]\n>;\n\nexport type HandlerServices<P extends Any> =\n | ActionHandlerServiceOf<P>\n | ([P[\"agentChannels\"][number]] extends [never]\n ? never\n : AgentChannel.Handler<`${P[\"identifier\"]}/${P[\"agentChannels\"][number][\"identifier\"]}`>)\n | (LocalTriggerEntries<P> extends infer Entry\n ? Entry extends { readonly localId: infer LocalId extends string }\n ? Trigger.Handler<CanonicalTriggerId<P, LocalId>>\n : never\n : never);\n\ninterface Declarations {\n readonly actions: unknown;\n readonly triggers: unknown;\n readonly agentChannels: unknown;\n}\n\n/* Missing handler declarations are builder defects, not expected failures, so\n they intentionally throw instead of entering the Effect failure channel. */\nconst missingDeclaration = (kind: string, localId: string, pluginId: string): never => {\n throw new Error(`missing ${kind} handler for \"${localId}\" in plugin \"${pluginId}\"`);\n};\n\nconst getNestedHandler = (handlers: unknown, localId: string): unknown => {\n let current = handlers;\n for (const segment of localId.split(MachineIdSeparator)) {\n if (!Predicate.hasProperty(current, segment)) return undefined;\n current = current[segment];\n }\n return current;\n};\n\n/** Register a plugin's handlers as one Context group keyed by the plugin. */\nexport const toHandlers = (\n plugin: Any,\n handlers: Declarations,\n): Effect.Effect<Context.Context<never>> =>\n Effect.gen(function* () {\n const
|
|
1
|
+
{"version":3,"file":"plugin-handlers.js","names":["Action.handlerKey","Trigger.handlerKey","AgentChannel.handlerKey"],"sources":["../../src/internal/plugin-handlers.ts"],"sourcesContent":["/** Plugin handler services and their registration. */\nimport { Context, Effect, Predicate } from \"effect\";\n\nimport * as Action from \"../Action.ts\";\nimport * as AgentChannel from \"../AgentChannel.ts\";\nimport type * as AuthMethod from \"../AuthMethod.ts\";\nimport type * as Group from \"../Group.ts\";\nimport type { Any } from \"../Plugin.ts\";\nimport * as Trigger from \"../Trigger.ts\";\n\nimport { walkCapabilities } from \"./capabilities.ts\";\nimport { handlerGroupKey, withoutGroups } from \"./handler-context.ts\";\nimport { MachineIdSeparator } from \"./identifier.ts\";\nimport type { IsGenericArray, JoinPrefix } from \"./types.ts\";\n\ntype LocalTriggerEntriesFromTriggers<\n Triggers extends readonly Trigger.Any[],\n Prefix extends string,\n AllowedMethods extends readonly AuthMethod.Any[],\n> = Triggers[number] extends infer TriggerDef\n ? TriggerDef extends Trigger.Any\n ? {\n readonly localId: JoinPrefix<Prefix, TriggerDef[\"identifier\"]>;\n readonly trigger: TriggerDef;\n readonly authMethods: AllowedMethods;\n }\n : never\n : never;\n\ntype LocalTriggerEntriesFromGroups<\n GroupDef extends Group.Any,\n Prefix extends string,\n AllowedMethods extends readonly AuthMethod.Any[],\n> = GroupDef extends unknown\n ?\n | LocalTriggerEntriesFromTriggers<\n GroupDef[\"triggers\"],\n JoinPrefix<Prefix, GroupDef[\"identifier\"]>,\n AllowedMethods\n >\n | (IsGenericArray<GroupDef[\"groups\"]> extends true\n ? LocalTriggerEntriesFromTriggers<readonly Trigger.Any[], string, AllowedMethods>\n : LocalTriggerEntriesFromGroups<\n GroupDef[\"groups\"][number],\n JoinPrefix<Prefix, GroupDef[\"identifier\"]>,\n AllowedMethods\n >)\n : never;\n\nexport type LocalTriggerEntries<P extends Any> =\n | LocalTriggerEntriesFromTriggers<P[\"triggers\"], \"\", P[\"authMethods\"]>\n | LocalTriggerEntriesFromGroups<P[\"groups\"][number], \"\", P[\"authMethods\"]>;\n\nexport type CanonicalTriggerId<\n P extends Any,\n LocalId extends string,\n> = `${P[\"identifier\"]}${typeof MachineIdSeparator}${LocalId}`;\n\n/** Keyed by the plugin's capabilities, which `Plugin.provide` keeps, so a Layer serves only them. */\nexport interface ActionHandlerService<\n in out PluginId extends string,\n in out Actions extends readonly unknown[],\n in out Groups extends readonly unknown[],\n> {\n readonly _: unique symbol;\n readonly pluginId: PluginId;\n readonly actions: Actions;\n readonly groups: Groups;\n}\n\nexport type ActionHandlerServiceOf<P extends Any> = ActionHandlerService<\n P[\"identifier\"],\n P[\"actions\"],\n P[\"groups\"]\n>;\n\nexport type HandlerServices<P extends Any> =\n | ActionHandlerServiceOf<P>\n | ([P[\"agentChannels\"][number]] extends [never]\n ? never\n : AgentChannel.Handler<`${P[\"identifier\"]}/${P[\"agentChannels\"][number][\"identifier\"]}`>)\n | (LocalTriggerEntries<P> extends infer Entry\n ? Entry extends { readonly localId: infer LocalId extends string }\n ? Trigger.Handler<CanonicalTriggerId<P, LocalId>>\n : never\n : never);\n\ninterface Declarations {\n readonly actions: unknown;\n readonly triggers: unknown;\n readonly agentChannels: unknown;\n}\n\n/* Missing handler declarations are builder defects, not expected failures, so\n they intentionally throw instead of entering the Effect failure channel. */\nconst missingDeclaration = (kind: string, localId: string, pluginId: string): never => {\n throw new Error(`missing ${kind} handler for \"${localId}\" in plugin \"${pluginId}\"`);\n};\n\nconst getNestedHandler = (handlers: unknown, localId: string): unknown => {\n let current = handlers;\n for (const segment of localId.split(MachineIdSeparator)) {\n if (!Predicate.hasProperty(current, segment)) return undefined;\n current = current[segment];\n }\n return current;\n};\n\n/** Register a plugin's handlers as one Context group keyed by the plugin. */\nexport const toHandlers = (\n plugin: Any,\n handlers: Declarations,\n): Effect.Effect<Context.Context<never>> =>\n Effect.gen(function* () {\n const context = yield* Effect.context();\n const services = withoutGroups(context);\n // Composed capability layers of the same plugin share one handler group.\n const inherited = context.mapUnsafe.get(handlerGroupKey(plugin.identifier));\n const map = new Map(Predicate.isMap(inherited) ? inherited : []);\n // A declared but invalid handler, such as `null` from JavaScript, fails when it is used.\n const find = (kind: string, declarations: unknown, localId: string) => {\n const handler = getNestedHandler(declarations, localId);\n return handler === undefined ? missingDeclaration(kind, localId, plugin.identifier) : handler;\n };\n\n for (const entry of walkCapabilities(plugin, owner => owner.actions)) {\n map.set(Action.handlerKey(entry.canonicalId), {\n actionId: entry.canonicalId,\n context: services,\n handler: find(\"action\", handlers.actions, entry.localId),\n });\n }\n for (const entry of walkCapabilities(plugin, owner => owner.triggers)) {\n map.set(Trigger.handlerKey(entry.canonicalId), {\n context: services,\n runtime: find(\"trigger\", handlers.triggers, entry.localId),\n triggerId: entry.canonicalId,\n });\n }\n for (const channel of plugin.agentChannels) {\n const channelId = `${plugin.identifier}/${channel.identifier}`;\n map.set(AgentChannel.handlerKey(channelId), {\n channelId,\n context: services,\n runtime: find(\"agent channel\", handlers.agentChannels, channel.identifier),\n });\n }\n return Context.makeUnsafe(new Map([[handlerGroupKey(plugin.identifier), map]]));\n });\n"],"mappings":";;;;;;;;;AA+FA,MAAM,sBAAsB,MAAc,SAAiB,aAA4B;CACrF,MAAM,IAAI,MAAM,WAAW,KAAK,gBAAgB,QAAQ,eAAe,SAAS,EAAE;AACpF;AAEA,MAAM,oBAAoB,UAAmB,YAA6B;CACxE,IAAI,UAAU;CACd,KAAK,MAAM,WAAW,QAAQ,MAAA,GAAwB,GAAG;EACvD,IAAI,CAAC,UAAU,YAAY,SAAS,OAAO,GAAG,OAAO,KAAA;EACrD,UAAU,QAAQ;CACpB;CACA,OAAO;AACT;;AAGA,MAAa,cACX,QACA,aAEA,OAAO,IAAI,aAAa;CACtB,MAAM,UAAU,OAAO,OAAO,QAAQ;CACtC,MAAM,WAAW,cAAc,OAAO;CAEtC,MAAM,YAAY,QAAQ,UAAU,IAAI,gBAAgB,OAAO,UAAU,CAAC;CAC1E,MAAM,MAAM,IAAI,IAAI,UAAU,MAAM,SAAS,IAAI,YAAY,CAAC,CAAC;CAE/D,MAAM,QAAQ,MAAc,cAAuB,YAAoB;EACrE,MAAM,UAAU,iBAAiB,cAAc,OAAO;EACtD,OAAO,YAAY,KAAA,IAAY,mBAAmB,MAAM,SAAS,OAAO,UAAU,IAAI;CACxF;CAEA,KAAK,MAAM,SAAS,iBAAiB,SAAQ,UAAS,MAAM,OAAO,GACjE,IAAI,IAAIA,WAAkB,MAAM,WAAW,GAAG;EAC5C,UAAU,MAAM;EAChB,SAAS;EACT,SAAS,KAAK,UAAU,SAAS,SAAS,MAAM,OAAO;CACzD,CAAC;CAEH,KAAK,MAAM,SAAS,iBAAiB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