boot.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. export * as PluginBoot from "./boot"
  2. import { Effect, Layer } from "effect"
  3. import { Integration } from "../integration"
  4. import { AgentV2 } from "../agent"
  5. import { AISDK } from "../aisdk"
  6. import { Catalog } from "../catalog"
  7. import { CommandV2 } from "../command"
  8. import { Config } from "../config"
  9. import { ConfigAgentPlugin } from "../config/plugin/agent"
  10. import { ConfigCommandPlugin } from "../config/plugin/command"
  11. import { ConfigSkillPlugin } from "../config/plugin/skill"
  12. import { ConfigReferencePlugin } from "../config/plugin/reference"
  13. import { ConfigExternalPlugin } from "../config/plugin/external"
  14. import { EventV2 } from "../event"
  15. import { FSUtil } from "../fs-util"
  16. import { FileSystem } from "../filesystem"
  17. import { Global } from "../global"
  18. import { Location } from "../location"
  19. import { ModelsDev } from "../models-dev"
  20. import { Npm } from "../npm"
  21. import { PluginV2 } from "../plugin"
  22. import { AgentPlugin } from "./agent"
  23. import { CommandPlugin } from "./command"
  24. import { SkillPlugin } from "./skill"
  25. import { ConfigProviderPlugin } from "../config/plugin/provider"
  26. import { ModelsDevPlugin } from "./models-dev"
  27. import { ProviderPlugins } from "./provider"
  28. import { SkillV2 } from "../skill"
  29. import { Reference } from "../reference"
  30. import { State } from "../state"
  31. import { PluginHost } from "./host"
  32. import { PluginInternal } from "./internal"
  33. export const locationLayer = Layer.effectDiscard(
  34. Effect.gen(function* () {
  35. const catalog = yield* Catalog.Service
  36. const commands = yield* CommandV2.Service
  37. const plugin = yield* PluginV2.Service
  38. const integration = yield* Integration.Service
  39. const agents = yield* AgentV2.Service
  40. const config = yield* Config.Service
  41. const location = yield* Location.Service
  42. const modelsDev = yield* ModelsDev.Service
  43. const npm = yield* Npm.Service
  44. const events = yield* EventV2.Service
  45. const fs = yield* FSUtil.Service
  46. const filesystem = yield* FileSystem.Service
  47. const global = yield* Global.Service
  48. const skill = yield* SkillV2.Service
  49. const reference = yield* Reference.Service
  50. const host = yield* PluginHost.make(plugin)
  51. const add = <R>(input: PluginInternal.Plugin<R>) =>
  52. input
  53. .effect({ ...host, options: {} })
  54. .pipe(
  55. Effect.provideService(Catalog.Service, catalog),
  56. Effect.provideService(CommandV2.Service, commands),
  57. Effect.provideService(Integration.Service, integration),
  58. Effect.provideService(AgentV2.Service, agents),
  59. Effect.provideService(Config.Service, config),
  60. Effect.provideService(Location.Service, location),
  61. Effect.provideService(ModelsDev.Service, modelsDev),
  62. Effect.provideService(Npm.Service, npm),
  63. Effect.provideService(EventV2.Service, events),
  64. Effect.provideService(FSUtil.Service, fs),
  65. Effect.provideService(FileSystem.Service, filesystem),
  66. Effect.provideService(Global.Service, global),
  67. Effect.provideService(SkillV2.Service, skill),
  68. Effect.provideService(Reference.Service, reference),
  69. )
  70. yield* State.batch(
  71. Effect.gen(function* () {
  72. yield* add(AgentPlugin.Plugin)
  73. yield* add(CommandPlugin.Plugin)
  74. yield* add(SkillPlugin.Plugin)
  75. yield* add(ModelsDevPlugin)
  76. yield* add(ConfigProviderPlugin.Plugin)
  77. yield* add(ConfigAgentPlugin.Plugin)
  78. yield* add(ConfigCommandPlugin.Plugin)
  79. yield* add(ConfigSkillPlugin.Plugin)
  80. yield* add(ConfigReferencePlugin.Plugin)
  81. for (const item of ProviderPlugins) yield* add(item)
  82. yield* add(ConfigExternalPlugin.Plugin)
  83. }),
  84. ).pipe(Effect.withSpan("PluginBoot.boot"))
  85. }),
  86. ).pipe(
  87. Layer.provideMerge(PluginV2.locationLayer),
  88. Layer.provideMerge(AISDK.locationLayer),
  89. Layer.provideMerge(Integration.locationLayer),
  90. Layer.provideMerge(Catalog.locationLayer),
  91. Layer.provideMerge(CommandV2.locationLayer),
  92. Layer.provideMerge(Config.locationLayer),
  93. Layer.provideMerge(AgentV2.locationLayer),
  94. Layer.provideMerge(SkillV2.locationLayer),
  95. Layer.provideMerge(Reference.locationLayer),
  96. Layer.provideMerge(FileSystem.locationLayer),
  97. )