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

Function createExecutor

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

Source from the content-addressed store, hash-verified

1536};
1537
1538export const createExecutor = <const TPlugins extends readonly AnyPlugin[] = readonly []>(
1539 config: ExecutorConfig<TPlugins>,
1540): Effect.Effect<Executor<TPlugins>, StorageFailure> =>
1541 Effect.gen(function* () {
1542 const defaultPlugins = (): TPlugins => {
1543 const empty: readonly AnyPlugin[] = [];
1544 return empty as TPlugins;
1545 };
1546 const { plugins: userPlugins = defaultPlugins() } = config;
1547
1548 const tenant = String(config.tenant);
1549 const subject = config.subject != null ? String(config.subject) : null;
1550
1551 const ownerBinding: OwnerBinding = {
1552 tenant: config.tenant,
1553 subject: config.subject ?? null,
1554 };
1555
1556 const ownedKeys = (owner: Owner): OwnedKeys => {
1557 if (owner === "org") return { tenant, owner, subject: ORG_SUBJECT };
1558 if (subject == null) {
1559 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: programmer error caught and surfaced as StorageError below by callers
1560 throw new StorageError({
1561 message: `Cannot target owner "user": executor has no subject.`,
1562 cause: undefined,
1563 });
1564 }
1565 return { tenant, owner, subject };
1566 };
1567
1568 const requireUserSubject = (owner: Owner): Effect.Effect<void, StorageFailure> =>
1569 owner === "user" && subject == null
1570 ? Effect.fail(
1571 new StorageError({
1572 message: `Cannot target owner "user": executor has no subject.`,
1573 cause: undefined,
1574 }),
1575 )
1576 : Effect.void;
1577
1578 // Built-in core-tools plugin: agent-facing static tools over the v2 surface.
1579 const plugins: readonly AnyPlugin[] = config.coreTools
1580 ? ([
1581 coreToolsPlugin({
1582 webBaseUrl: config.coreTools.webBaseUrl,
1583 orgSlug: config.coreTools.orgSlug,
1584 includeProviders: config.coreTools.includeProviders,
1585 }),
1586 ...userPlugins,
1587 ] as readonly AnyPlugin[])
1588 : (userPlugins as readonly AnyPlugin[]);
1589
1590 const tables = yield* Effect.try({
1591 try: () => collectTables(),
1592 catch: (cause) => storageFailureFromUnknown("Failed to collect executor tables", cause),
1593 });
1594 const dbInput = yield* Effect.suspend(() => {
1595 if (!config.db) return Effect.succeed(createDefaultMemoryDb(tables));

Callers 15

makePlatformExecutorFunction · 0.90
makeTestWorkspaceHarnessFunction · 0.90
makeScopedExecutorFunction · 0.90
makePlatformExecutorFunction · 0.90
platformExecutorForFunction · 0.90
productExecutorForFunction · 0.90
makeExecutorFunction · 0.90
makeExecutorWithFunction · 0.90

Calls 15

withQueryContextFunction · 0.90
makeFumaClientFunction · 0.90
makeFumaBlobStoreFunction · 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

makePlatformExecutorFunction · 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
buildExecutorFunction · 0.72