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

Function createExecutor

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

Source from the content-addressed store, hash-verified

1275};
1276
1277export const createExecutor = <const TPlugins extends readonly AnyPlugin[] = readonly []>(
1278 config: ExecutorConfig<TPlugins>,
1279): Effect.Effect<Executor<TPlugins>, StorageFailure> =>
1280 Effect.gen(function* () {
1281 const defaultPlugins = (): TPlugins => {
1282 const empty: readonly AnyPlugin[] = [];
1283 return empty as TPlugins;
1284 };
1285 const { plugins: userPlugins = defaultPlugins() } = config;
1286
1287 const tenant = String(config.tenant);
1288 const subject = config.subject != null ? String(config.subject) : null;
1289
1290 const ownerBinding: OwnerBinding = {
1291 tenant: config.tenant,
1292 subject: config.subject ?? null,
1293 };
1294
1295 const ownedKeys = (owner: Owner): OwnedKeys => {
1296 if (owner === "org") return { tenant, owner, subject: ORG_SUBJECT };
1297 if (subject == null) {
1298 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: programmer error caught and surfaced as StorageError below by callers
1299 throw new StorageError({
1300 message: `Cannot target owner "user": executor has no subject.`,
1301 cause: undefined,
1302 });
1303 }
1304 return { tenant, owner, subject };
1305 };
1306
1307 const requireUserSubject = (owner: Owner): Effect.Effect<void, StorageFailure> =>
1308 owner === "user" && subject == null
1309 ? Effect.fail(
1310 new StorageError({
1311 message: `Cannot target owner "user": executor has no subject.`,
1312 cause: undefined,
1313 }),
1314 )
1315 : Effect.void;
1316
1317 // Built-in core-tools plugin: agent-facing static tools over the v2 surface.
1318 const plugins: readonly AnyPlugin[] = config.coreTools
1319 ? ([
1320 coreToolsPlugin({
1321 webBaseUrl: config.coreTools.webBaseUrl,
1322 orgSlug: config.coreTools.orgSlug,
1323 includeProviders: config.coreTools.includeProviders,
1324 }),
1325 ...userPlugins,
1326 ] as readonly AnyPlugin[])
1327 : (userPlugins as readonly AnyPlugin[]);
1328
1329 const tables = yield* Effect.try({
1330 try: () => collectTables(),
1331 catch: (cause) => storageFailureFromUnknown("Failed to collect executor tables", cause),
1332 });
1333 const dbInput = yield* Effect.suspend(() => {
1334 if (!config.db) return Effect.succeed(createDefaultMemoryDb(tables));

Callers 15

makeTestWorkspaceHarnessFunction · 0.90
makeScopedExecutorFunction · 0.90
makeExecutorFunction · 0.90
makeExecutorWithFunction · 0.90
plugin.test.tsFile · 0.90
spec-blob.test.tsFile · 0.90
getRegisteredToolSchemaFunction · 0.90

Calls 15

withQueryContextFunction · 0.90
makeFumaClientFunction · 0.90
makeFumaBlobStoreFunction · 0.90
makeOAuthServiceFunction · 0.90
pluginBlobStoreFunction · 0.90
defaultPluginsFunction · 0.85
collectTablesFunction · 0.85
createDefaultMemoryDbFunction · 0.85
validateExecutorDbTablesFunction · 0.85
makeCoreDbFunction · 0.85

Tested by 15

makeExecutorFunction · 0.72
makeExecutorWithFunction · 0.72
getRegisteredToolSchemaFunction · 0.72
buildExecutorFunction · 0.72
makeTestExecutorFunction · 0.72
makeCatalogTestExecutorFunction · 0.72
seedCallToolExecutorFunction · 0.72
seedAnnotationsExecutorFunction · 0.72
runEndpointProbeFunction · 0.72
makeExecutorFunction · 0.72
makeExecutorFunction · 0.72