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

Function createExecutor

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

Source from the content-addressed store, hash-verified

1574};
1575
1576export const createExecutor = <const TPlugins extends readonly AnyPlugin[] = readonly []>(
1577 config: ExecutorConfig<TPlugins>,
1578): Effect.Effect<Executor<TPlugins>, StorageFailure> =>
1579 Effect.gen(function* () {
1580 const defaultPlugins = (): TPlugins => {
1581 const empty: readonly AnyPlugin[] = [];
1582 return empty as TPlugins;
1583 };
1584 const { plugins: userPlugins = defaultPlugins() } = config;
1585
1586 const tenant = String(config.tenant);
1587 const subject = config.subject != null ? String(config.subject) : null;
1588
1589 const ownerBinding: OwnerBinding = {
1590 tenant: config.tenant,
1591 subject: config.subject ?? null,
1592 };
1593
1594 const ownedKeys = (owner: Owner): OwnedKeys => {
1595 if (owner === "org") return { tenant, owner, subject: ORG_SUBJECT };
1596 if (subject == null) {
1597 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: programmer error caught and surfaced as StorageError below by callers
1598 throw new StorageError({
1599 message: `Cannot target owner "user": executor has no subject.`,
1600 cause: undefined,
1601 });
1602 }
1603 return { tenant, owner, subject };
1604 };
1605
1606 const requireUserSubject = (owner: Owner): Effect.Effect<void, StorageFailure> =>
1607 owner === "user" && subject == null
1608 ? Effect.fail(
1609 new StorageError({
1610 message: `Cannot target owner "user": executor has no subject.`,
1611 cause: undefined,
1612 }),
1613 )
1614 : Effect.void;
1615
1616 // Built-in core-tools plugin: agent-facing static tools over the v2 surface.
1617 const plugins: readonly AnyPlugin[] = config.coreTools
1618 ? ([
1619 coreToolsPlugin({
1620 webBaseUrl: config.coreTools.webBaseUrl,
1621 orgSlug: config.coreTools.orgSlug,
1622 includeProviders: config.coreTools.includeProviders,
1623 }),
1624 ...userPlugins,
1625 ] as readonly AnyPlugin[])
1626 : (userPlugins as readonly AnyPlugin[]);
1627
1628 const tables = yield* Effect.try({
1629 try: () => collectTables(),
1630 catch: (cause) => storageFailureFromUnknown("Failed to collect executor tables", cause),
1631 });
1632 const dbInput = yield* Effect.suspend(() => {
1633 if (!config.db) return Effect.succeed(createDefaultMemoryDb(tables));

Callers 15

executorWithConnectionFunction · 0.90
makePlatformExecutorFunction · 0.90
failInvokingFunction · 0.90
makeTestWorkspaceHarnessFunction · 0.90
makeScopedExecutorFunction · 0.90
makePlatformExecutorFunction · 0.90
platformExecutorForFunction · 0.90
productExecutorForFunction · 0.90

Calls 15

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

Tested by 15

executorWithConnectionFunction · 0.72
makePlatformExecutorFunction · 0.72
failInvokingFunction · 0.72
platformExecutorForFunction · 0.72
productExecutorForFunction · 0.72
makeExecutorFunction · 0.72
makeExecutorWithFunction · 0.72
startMcpHarnessFunction · 0.72
buildExecutorFunction · 0.72
buildExecutorFunction · 0.72
getRegisteredToolSchemaFunction · 0.72
buildExecutorFunction · 0.72