MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / createExecutor

Function createExecutor

packages/core/sdk/src/promise-executor.ts:203–234  ·  view source on GitHub ↗
(
  config: ExecutorConfig<TPlugins>,
)

Source from the content-addressed store, hash-verified

201// ---------------------------------------------------------------------------
202
203export const createExecutor = async <const TPlugins extends readonly AnyPlugin[] = readonly []>(
204 config: ExecutorConfig<TPlugins>,
205): Promise<Executor<TPlugins>> => {
206 const plugins = (config?.plugins ?? []) as TPlugins;
207 const db =
208 typeof config.db === "function" ? await config.db({ tables: collectTables() }) : config.db;
209
210 const effectConfig = {
211 tenant: Tenant.make(config.tenant ?? "default-tenant"),
212 ...(config.subject !== undefined ? { subject: Subject.make(config.subject) } : {}),
213 plugins,
214 ...(config.providers ? { providers: config.providers } : {}),
215 onElicitation: toEffectOnElicitation(config.onElicitation),
216 ...(db ? { db } : {}),
217 };
218
219 // The SDK has no observability requirement; storage failures surface
220 // as raw `StorageError` / `UniqueViolationError` in the typed channel.
221 // `Effect.runPromise` turns them into Promise rejections — consumers
222 // get the tagged error as the rejected value. See
223 // notes/promise-sdk-typed-errors.md for the planned `runPromiseExit`
224 // rewrite that exposes the full error union to consumers.
225 const effectExecutor = await Effect.runPromise(createEffectExecutor(effectConfig));
226
227 const executor = promisifyDeep(effectExecutor) as Executor<TPlugins>;
228 return {
229 ...executor,
230 close: async () => {
231 await Effect.runPromise(effectExecutor.close());
232 },
233 } as Executor<TPlugins>;
234};

Callers 3

promise.test.tsFile · 0.90
main.tsFile · 0.90
main.tsFile · 0.90

Calls 4

collectTablesFunction · 0.90
toEffectOnElicitationFunction · 0.85
promisifyDeepFunction · 0.85
closeMethod · 0.65

Tested by

no test coverage detected