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

Function createExecutor

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

Source from the content-addressed store, hash-verified

1874};
1875
1876export const createExecutor = <const TPlugins extends readonly AnyPlugin[] = readonly []>(
1877 config: ExecutorConfig<TPlugins>,
1878): Effect.Effect<Executor<TPlugins>, StorageFailure> =>
1879 Effect.gen(function* () {
1880 const defaultPlugins = (): TPlugins => {
1881 const empty: readonly AnyPlugin[] = [];
1882 return empty as TPlugins;
1883 };
1884 const { plugins: userPlugins = defaultPlugins() } = config;
1885
1886 const tenant = String(config.tenant);
1887 const subject = config.subject != null ? String(config.subject) : null;
1888
1889 const ownerBinding: OwnerBinding = {
1890 tenant: config.tenant,
1891 subject: config.subject ?? null,
1892 };
1893
1894 const ownedKeys = (owner: Owner): OwnedKeys => {
1895 if (owner === "org") return { tenant, owner, subject: ORG_SUBJECT };
1896 if (subject == null) {
1897 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: programmer error caught and surfaced as StorageError below by callers
1898 throw new StorageError({
1899 message: `Cannot target owner "user": executor has no subject.`,
1900 cause: undefined,
1901 });
1902 }
1903 return { tenant, owner, subject };
1904 };
1905
1906 const requireUserSubject = (owner: Owner): Effect.Effect<void, StorageFailure> =>
1907 owner === "user" && subject == null
1908 ? Effect.fail(
1909 new StorageError({
1910 message: `Cannot target owner "user": executor has no subject.`,
1911 cause: undefined,
1912 }),
1913 )
1914 : Effect.void;
1915
1916 // Workspace-settings gate (`ExecutorConfig.orgWrites`). Called at the top
1917 // of every user-intent workspace-level mutation: with an explicit owner it
1918 // refuses only `"org"` targets; with no owner it guards a tenant-shared
1919 // surface outright. Deliberately NOT wired into the storage owner policy —
1920 // operational org-row writes (token refresh, tool-catalog re-sync) must
1921 // keep working for a denied member.
1922 const guardOrgWrite = (owner?: Owner): Effect.Effect<void, OrgWriteDeniedError> =>
1923 Effect.gen(function* () {
1924 const access =
1925 config.orgWrites === "request" ? yield* currentOrgWriteAccess : config.orgWrites;
1926 if (access === "denied" && (owner === undefined || owner === "org")) {
1927 return yield* new OrgWriteDeniedError();
1928 }
1929 });
1930
1931 // Built-in core-tools plugin: agent-facing static tools over the v2 surface.
1932 const plugins: readonly AnyPlugin[] = config.coreTools
1933 ? ([

Callers 15

executorWithConnectionFunction · 0.90
makePlatformExecutorFunction · 0.90
failInvokingFunction · 0.90
recordToolRowLaunchFunction · 0.90
recordCredentialLaunchFunction · 0.90
executor.test.tsFile · 0.90
makeTestWorkspaceHarnessFunction · 0.90
makeHealthHarnessFunction · 0.90
setupFunction · 0.90
org-writes.test.tsFile · 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
afterCommitFunction · 0.90
defaultPluginsFunction · 0.85
collectTablesFunction · 0.85
createDefaultMemoryDbFunction · 0.85

Tested by 15

executorWithConnectionFunction · 0.72
makePlatformExecutorFunction · 0.72
failInvokingFunction · 0.72
recordToolRowLaunchFunction · 0.72
recordCredentialLaunchFunction · 0.72
makeHealthHarnessFunction · 0.72
setupFunction · 0.72
platformExecutorForFunction · 0.72
productExecutorForFunction · 0.72
makeExecutorFunction · 0.72
makeExecutorWithFunction · 0.72
startMcpHarnessFunction · 0.72