import { toTool, type ToolMap } from "@executor/codemode-core";import type { Executor } from "@executor/platform-sdk";import { type ScopeId as AccountId, LocalInstallationSchema, LocalScopePolicySchema, SourceDiscoveryResultSchema, SourceIdSchema, SourceInspectionDiscoverPayloadSchema, SourceInspectionDiscoverResultSchema, SourceInspectionSchema, SourceInspectionToolDetailSchema, SourceSchema, type ScopeId as WorkspaceId, ScopeOauthClientSchema,} from "@executor/platform-sdk/schema";import * as Effect from "effect/Effect";import * as Layer from "effect/Layer";import * as Schema from "effect/Schema"; import { ExecutorStateStore, LocalInstanceConfigService, SecretMaterialDeleterService, SecretMaterialStorerService, SecretMaterialUpdaterService, type ExecutorStateStoreShape, type ScopeInternalToolContext as WorkspaceInternalToolContext, RuntimeSourceAuthService, RuntimeSourceCatalogSyncService, RuntimeSourceStore, RuntimeSourceStoreService,} from "@executor/platform-sdk/runtime";import { type RuntimeLocalScopeState, provideOptionalRuntimeLocalScope,} from "../../../sdk/src/runtime/scope/runtime-context";import { SourceArtifactStore, type SourceArtifactStoreShape, ScopeConfigStore, type ScopeConfigStoreShape, ScopeStateStore, type ScopeStateStoreShape, makeScopeStorageLayer,} from "../../../sdk/src/runtime/scope/storage";import { CreateSecretPayloadSchema, CreateSecretResultSchema, type CreateSecretPayload, DeleteSecretResultSchema, InstanceConfigSchema, SecretListItemSchema, UpdateSecretPayloadSchema, UpdateSecretResultSchema, type UpdateSecretPayload,} from "@executor/platform-sdk/contracts";import { createLocalSecret, createPolicy, deleteLocalSecret, discoverSource, discoverSourceInspectionTools, getPolicy, getSource, getSourceInspection, getSourceInspectionToolDetail, listLocalSecrets, listPolicies, listSources, removePolicy, removeSource, updateLocalSecret, updatePolicy, updateSource,} from "@executor/platform-sdk/operations";import { CreatePolicyPayloadSchema, type CreatePolicyPayload, type UpdatePolicyPayload, UpdatePolicyPayloadSchema,} from "@executor/platform-sdk/contracts";import { CreateScopeOauthClientPayloadSchema, DiscoverSourcePayloadSchema, type CreateScopeOauthClientPayload as CreateWorkspaceOauthClientPayload, UpdateSourcePayloadSchema,} from "@executor/platform-sdk/contracts"; const emptyInputSchema = Schema.standardSchemaV1(Schema.Struct({}));const localInstallationOutputSchema = Schema.standardSchemaV1( LocalInstallationSchema,);const instanceConfigOutputSchema = Schema.standardSchemaV1(InstanceConfigSchema);const secretListOutputSchema = Schema.standardSchemaV1( Schema.Array(SecretListItemSchema),);const createSecretInputSchema = Schema.standardSchemaV1( CreateSecretPayloadSchema,);const updateSecretInputSchema = Schema.standardSchemaV1( Schema.Struct({ secretId: Schema.String, payload: UpdateSecretPayloadSchema, }),);const removeSecretInputSchema = Schema.standardSchemaV1( Schema.Struct({ secretId: Schema.String, }),);const removeResultSchema = Schema.standardSchemaV1( Schema.Struct({ removed: Schema.Boolean, }),);const listSourcesOutputSchema = Schema.standardSchemaV1( Schema.Array(SourceSchema),);const getSourceInputSchema = Schema.standardSchemaV1( Schema.Struct({ sourceId: SourceIdSchema, }),);const updateSourceInputSchema = Schema.standardSchemaV1( Schema.Struct({ sourceId: SourceIdSchema, payload: UpdateSourcePayloadSchema, }),);const discoverSourceInputSchema = Schema.standardSchemaV1( DiscoverSourcePayloadSchema,);const inspectToolInputSchema = Schema.standardSchemaV1( Schema.Struct({ sourceId: SourceIdSchema, toolPath: Schema.String, }),);const inspectDiscoverInputSchema = Schema.standardSchemaV1( Schema.Struct({ sourceId: SourceIdSchema, payload: SourceInspectionDiscoverPayloadSchema, }),);const listPoliciesOutputSchema = Schema.standardSchemaV1( Schema.Array(LocalScopePolicySchema),);const policyIdInputSchema = Schema.standardSchemaV1( Schema.Struct({ policyId: Schema.String, }),);const createPolicyInputSchema = Schema.standardSchemaV1( CreatePolicyPayloadSchema,);const updatePolicyInputSchema = Schema.standardSchemaV1( Schema.Struct({ policyId: Schema.String, payload: UpdatePolicyPayloadSchema, }),);const workspaceOauthClientListInputSchema = Schema.standardSchemaV1( Schema.Struct({ providerKey: Schema.String, }),);const workspaceOauthClientListOutputSchema = Schema.standardSchemaV1( Schema.Array(ScopeOauthClientSchema),);const createWorkspaceOauthClientInputSchema = Schema.standardSchemaV1( CreateScopeOauthClientPayloadSchema,);const removeWorkspaceOauthClientInputSchema = Schema.standardSchemaV1( Schema.Struct({ oauthClientId: Schema.String, }),);const removeProviderGrantInputSchema = Schema.standardSchemaV1( Schema.Struct({ grantId: Schema.String, }),);const sourceOutputSchema = Schema.standardSchemaV1(SourceSchema);const sourceInspectionOutputSchema = Schema.standardSchemaV1( SourceInspectionSchema,);const sourceInspectionToolOutputSchema = Schema.standardSchemaV1( SourceInspectionToolDetailSchema,);const sourceInspectionDiscoverOutputSchema = Schema.standardSchemaV1( SourceInspectionDiscoverResultSchema,);const sourceDiscoveryOutputSchema = Schema.standardSchemaV1( SourceDiscoveryResultSchema,);const localScopePolicyOutputSchema = Schema.standardSchemaV1( LocalScopePolicySchema,); const makeRuntimeLayer = (input: { executorStateStore: ExecutorStateStoreShape; sourceStore: RuntimeSourceStore; sourceCatalogSyncService: Effect.Effect.Success< typeof RuntimeSourceCatalogSyncService >; scopeConfigStore: ScopeConfigStoreShape; scopeStateStore: ScopeStateStoreShape; sourceArtifactStore: SourceArtifactStoreShape; instanceConfigResolver: WorkspaceInternalToolContext["instanceConfigResolver"]; storeSecretMaterial: WorkspaceInternalToolContext["storeSecretMaterial"]; deleteSecretMaterial: WorkspaceInternalToolContext["deleteSecretMaterial"]; updateSecretMaterial: WorkspaceInternalToolContext["updateSecretMaterial"];}) => Layer.mergeAll( Layer.succeed(ExecutorStateStore, input.executorStateStore), Layer.succeed(RuntimeSourceStoreService, input.sourceStore), Layer.succeed( RuntimeSourceCatalogSyncService, input.sourceCatalogSyncService, ), Layer.succeed(LocalInstanceConfigService, input.instanceConfigResolver), Layer.succeed(SecretMaterialStorerService, input.storeSecretMaterial), Layer.succeed(SecretMaterialDeleterService, input.deleteSecretMaterial), Layer.succeed(SecretMaterialUpdaterService, input.updateSecretMaterial), makeScopeStorageLayer({ scopeConfigStore: input.scopeConfigStore, scopeStateStore: input.scopeStateStore, sourceArtifactStore: input.sourceArtifactStore, }), ); const runRuntimeEffect = <A, E, R>(input: { effect: Effect.Effect<A, E, R>; runtimeLayer: Layer.Layer< | ExecutorStateStore | LocalInstanceConfigService | RuntimeSourceStoreService | RuntimeSourceCatalogSyncService | SecretMaterialStorerService | SecretMaterialDeleterService | SecretMaterialUpdaterService | ScopeConfigStore | ScopeStateStore | SourceArtifactStore, never, never >; runtimeLocalScope: RuntimeLocalScopeState | null;}) => Effect.runPromise( provideOptionalRuntimeLocalScope( input.effect.pipe(Effect.provide(input.runtimeLayer)), input.runtimeLocalScope, ) as Effect.Effect<A, E, never>, ); const runScopeStorageEffect = <A, E, R>(input: { effect: Effect.Effect<A, E, R>; scopeStorageLayer: Layer.Layer< ScopeConfigStore | ScopeStateStore | SourceArtifactStore, never, never >; runtimeLocalScope: RuntimeLocalScopeState | null;}) => Effect.runPromise( provideOptionalRuntimeLocalScope( input.effect.pipe(Effect.provide(input.scopeStorageLayer)), input.runtimeLocalScope, ) as Effect.Effect<A, E, never>, ); export const createWorkspaceExecutorAdminToolMap = ( input: WorkspaceInternalToolContext,): ToolMap => { const runtimeLayer = makeRuntimeLayer({ executorStateStore: input.executorStateStore, sourceStore: input.sourceStore, sourceCatalogSyncService: input.sourceCatalogSyncService, scopeConfigStore: input.scopeConfigStore, scopeStateStore: input.scopeStateStore, sourceArtifactStore: input.sourceArtifactStore, instanceConfigResolver: input.instanceConfigResolver, storeSecretMaterial: input.storeSecretMaterial, deleteSecretMaterial: input.deleteSecretMaterial, updateSecretMaterial: input.updateSecretMaterial, }); const scopeStorageLayer = makeScopeStorageLayer({ scopeConfigStore: input.scopeConfigStore, scopeStateStore: input.scopeStateStore, sourceArtifactStore: input.sourceArtifactStore, }); const metadata = { sourceKey: "executor", interaction: "auto" as const, }; return { "executor.local.installation.get": toTool({ tool: { description: "Get the active local executor installation account and workspace ids.", inputSchema: emptyInputSchema, outputSchema: localInstallationOutputSchema, execute: async () => ({ scopeId: input.scopeId, actorScopeId: input.actorScopeId, }), }, metadata, }), "executor.local.config.get": toTool({ tool: { description: "Get local instance config such as supported secret providers.", inputSchema: emptyInputSchema, outputSchema: instanceConfigOutputSchema, execute: () => Effect.runPromise(input.instanceConfigResolver()), }, metadata, }), "executor.secrets.list": toTool({ tool: { description: "List locally stored secrets and the sources linked to them.", inputSchema: emptyInputSchema, outputSchema: secretListOutputSchema, execute: () => runRuntimeEffect({ effect: listLocalSecrets(), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.secrets.create": toTool({ tool: { description: "Create a local secret without putting the raw value into source config.", inputSchema: createSecretInputSchema, outputSchema: Schema.standardSchemaV1(CreateSecretResultSchema), execute: (payload: CreateSecretPayload) => runRuntimeEffect({ effect: createLocalSecret(payload), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.secrets.update": toTool({ tool: { description: "Update a stored secret name and optionally rotate its value.", inputSchema: updateSecretInputSchema, outputSchema: Schema.standardSchemaV1(UpdateSecretResultSchema), execute: (payload: { secretId: string; payload: UpdateSecretPayload; }) => runRuntimeEffect({ effect: updateLocalSecret(payload), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.secrets.remove": toTool({ tool: { description: "Remove a stored local secret.", inputSchema: removeSecretInputSchema, outputSchema: Schema.standardSchemaV1(DeleteSecretResultSchema), execute: ({ secretId }: { secretId: string }) => runRuntimeEffect({ effect: deleteLocalSecret(secretId), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.sources.discover": toTool({ tool: { description: "Probe a URL and infer whether it looks like MCP, OpenAPI, GraphQL, or another supported source.", inputSchema: discoverSourceInputSchema, outputSchema: sourceDiscoveryOutputSchema, execute: (payload: { url: string; probeAuth?: unknown }) => Effect.runPromise( discoverSource({ url: payload.url, probeAuth: payload.probeAuth as never, }), ), }, metadata, }), "executor.sources.list": toTool({ tool: { description: "List sources connected in the current workspace.", inputSchema: emptyInputSchema, outputSchema: listSourcesOutputSchema, execute: () => runRuntimeEffect({ effect: listSources({ scopeId: input.scopeId, actorScopeId: input.actorScopeId as never, }), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.sources.get": toTool({ tool: { description: "Get one source by id.", inputSchema: getSourceInputSchema, outputSchema: sourceOutputSchema, execute: ({ sourceId }: { sourceId: string }) => runRuntimeEffect({ effect: getSource({ scopeId: input.scopeId, sourceId: sourceId as never, actorScopeId: input.actorScopeId as never, }), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.sources.update": toTool({ tool: { description: "Update a source definition in the current workspace.", inputSchema: updateSourceInputSchema, outputSchema: sourceOutputSchema, execute: (payload: { sourceId: string; payload: Record<string, unknown>; }) => runRuntimeEffect({ effect: updateSource({ scopeId: input.scopeId, sourceId: payload.sourceId as never, actorScopeId: input.actorScopeId as never, payload: payload.payload as never, }), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.sources.remove": toTool({ tool: { description: "Remove a source from the current workspace.", inputSchema: getSourceInputSchema, outputSchema: removeResultSchema, execute: ({ sourceId }: { sourceId: string }) => runRuntimeEffect({ effect: removeSource({ scopeId: input.scopeId, sourceId: sourceId as never, }), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.sources.inspect.get": toTool({ tool: { description: "Inspect the tool model for one connected source.", inputSchema: getSourceInputSchema, outputSchema: sourceInspectionOutputSchema, execute: ({ sourceId }: { sourceId: string }) => runRuntimeEffect({ effect: getSourceInspection({ scopeId: input.scopeId, sourceId: sourceId as never, }), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.sources.inspect.tool": toTool({ tool: { description: "Inspect one tool inside a connected source.", inputSchema: inspectToolInputSchema, outputSchema: sourceInspectionToolOutputSchema, execute: ({ sourceId,Lines 1–500 of 998. Load more
import { toTool, type ToolMap } from "@executor/codemode-core"; import type { Executor } from "@executor/platform-sdk"; import { type ScopeId as AccountId, LocalInstallationSchema, LocalScopePolicySchema, SourceDiscoveryResultSchema, SourceIdSchema, SourceInspectionDiscoverPayloadSchema, SourceInspectionDiscoverResultSchema, SourceInspectionSchema, SourceInspectionToolDetailSchema, SourceSchema, type ScopeId as WorkspaceId, ScopeOauthClientSchema, } from "@executor/platform-sdk/schema"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; import * as Schema from "effect/Schema"; import { ExecutorStateStore, LocalInstanceConfigService, SecretMaterialDeleterService, SecretMaterialStorerService, SecretMaterialUpdaterService, type ExecutorStateStoreShape, type ScopeInternalToolContext as WorkspaceInternalToolContext, RuntimeSourceAuthService, RuntimeSourceCatalogSyncService, RuntimeSourceStore, RuntimeSourceStoreService, } from "@executor/platform-sdk/runtime"; import { type RuntimeLocalScopeState, provideOptionalRuntimeLocalScope, } from "../../../sdk/src/runtime/scope/runtime-context"; import { SourceArtifactStore, type SourceArtifactStoreShape, ScopeConfigStore, type ScopeConfigStoreShape, ScopeStateStore, type ScopeStateStoreShape, makeScopeStorageLayer, } from "../../../sdk/src/runtime/scope/storage"; import { CreateSecretPayloadSchema, CreateSecretResultSchema, type CreateSecretPayload, DeleteSecretResultSchema, InstanceConfigSchema, SecretListItemSchema, UpdateSecretPayloadSchema, UpdateSecretResultSchema, type UpdateSecretPayload, } from "@executor/platform-sdk/contracts"; import { createLocalSecret, createPolicy, deleteLocalSecret, discoverSource, discoverSourceInspectionTools, getPolicy, getSource, getSourceInspection, getSourceInspectionToolDetail, listLocalSecrets, listPolicies, listSources, removePolicy, removeSource, updateLocalSecret, updatePolicy, updateSource, } from "@executor/platform-sdk/operations"; import { CreatePolicyPayloadSchema, type CreatePolicyPayload, type UpdatePolicyPayload, UpdatePolicyPayloadSchema, } from "@executor/platform-sdk/contracts"; import { CreateScopeOauthClientPayloadSchema, DiscoverSourcePayloadSchema, type CreateScopeOauthClientPayload as CreateWorkspaceOauthClientPayload, UpdateSourcePayloadSchema, } from "@executor/platform-sdk/contracts"; const emptyInputSchema = Schema.standardSchemaV1(Schema.Struct({})); const localInstallationOutputSchema = Schema.standardSchemaV1( LocalInstallationSchema, ); const instanceConfigOutputSchema = Schema.standardSchemaV1(InstanceConfigSchema); const secretListOutputSchema = Schema.standardSchemaV1( Schema.Array(SecretListItemSchema), ); const createSecretInputSchema = Schema.standardSchemaV1( CreateSecretPayloadSchema, ); const updateSecretInputSchema = Schema.standardSchemaV1( Schema.Struct({ secretId: Schema.String, payload: UpdateSecretPayloadSchema, }), ); const removeSecretInputSchema = Schema.standardSchemaV1( Schema.Struct({ secretId: Schema.String, }), ); const removeResultSchema = Schema.standardSchemaV1( Schema.Struct({ removed: Schema.Boolean, }), ); const listSourcesOutputSchema = Schema.standardSchemaV1( Schema.Array(SourceSchema), ); const getSourceInputSchema = Schema.standardSchemaV1( Schema.Struct({ sourceId: SourceIdSchema, }), ); const updateSourceInputSchema = Schema.standardSchemaV1( Schema.Struct({ sourceId: SourceIdSchema, payload: UpdateSourcePayloadSchema, }), ); const discoverSourceInputSchema = Schema.standardSchemaV1( DiscoverSourcePayloadSchema, ); const inspectToolInputSchema = Schema.standardSchemaV1( Schema.Struct({ sourceId: SourceIdSchema, toolPath: Schema.String, }), ); const inspectDiscoverInputSchema = Schema.standardSchemaV1( Schema.Struct({ sourceId: SourceIdSchema, payload: SourceInspectionDiscoverPayloadSchema, }), ); const listPoliciesOutputSchema = Schema.standardSchemaV1( Schema.Array(LocalScopePolicySchema), ); const policyIdInputSchema = Schema.standardSchemaV1( Schema.Struct({ policyId: Schema.String, }), ); const createPolicyInputSchema = Schema.standardSchemaV1( CreatePolicyPayloadSchema, ); const updatePolicyInputSchema = Schema.standardSchemaV1( Schema.Struct({ policyId: Schema.String, payload: UpdatePolicyPayloadSchema, }), ); const workspaceOauthClientListInputSchema = Schema.standardSchemaV1( Schema.Struct({ providerKey: Schema.String, }), ); const workspaceOauthClientListOutputSchema = Schema.standardSchemaV1( Schema.Array(ScopeOauthClientSchema), ); const createWorkspaceOauthClientInputSchema = Schema.standardSchemaV1( CreateScopeOauthClientPayloadSchema, ); const removeWorkspaceOauthClientInputSchema = Schema.standardSchemaV1( Schema.Struct({ oauthClientId: Schema.String, }), ); const removeProviderGrantInputSchema = Schema.standardSchemaV1( Schema.Struct({ grantId: Schema.String, }), ); const sourceOutputSchema = Schema.standardSchemaV1(SourceSchema); const sourceInspectionOutputSchema = Schema.standardSchemaV1( SourceInspectionSchema, ); const sourceInspectionToolOutputSchema = Schema.standardSchemaV1( SourceInspectionToolDetailSchema, ); const sourceInspectionDiscoverOutputSchema = Schema.standardSchemaV1( SourceInspectionDiscoverResultSchema, ); const sourceDiscoveryOutputSchema = Schema.standardSchemaV1( SourceDiscoveryResultSchema, ); const localScopePolicyOutputSchema = Schema.standardSchemaV1( LocalScopePolicySchema, ); const makeRuntimeLayer = (input: { executorStateStore: ExecutorStateStoreShape; sourceStore: RuntimeSourceStore; sourceCatalogSyncService: Effect.Effect.Success< typeof RuntimeSourceCatalogSyncService >; scopeConfigStore: ScopeConfigStoreShape; scopeStateStore: ScopeStateStoreShape; sourceArtifactStore: SourceArtifactStoreShape; instanceConfigResolver: WorkspaceInternalToolContext["instanceConfigResolver"]; storeSecretMaterial: WorkspaceInternalToolContext["storeSecretMaterial"]; deleteSecretMaterial: WorkspaceInternalToolContext["deleteSecretMaterial"]; updateSecretMaterial: WorkspaceInternalToolContext["updateSecretMaterial"]; }) => Layer.mergeAll( Layer.succeed(ExecutorStateStore, input.executorStateStore), Layer.succeed(RuntimeSourceStoreService, input.sourceStore), Layer.succeed( RuntimeSourceCatalogSyncService, input.sourceCatalogSyncService, ), Layer.succeed(LocalInstanceConfigService, input.instanceConfigResolver), Layer.succeed(SecretMaterialStorerService, input.storeSecretMaterial), Layer.succeed(SecretMaterialDeleterService, input.deleteSecretMaterial), Layer.succeed(SecretMaterialUpdaterService, input.updateSecretMaterial), makeScopeStorageLayer({ scopeConfigStore: input.scopeConfigStore, scopeStateStore: input.scopeStateStore, sourceArtifactStore: input.sourceArtifactStore, }), ); const runRuntimeEffect = <A, E, R>(input: { effect: Effect.Effect<A, E, R>; runtimeLayer: Layer.Layer< | ExecutorStateStore | LocalInstanceConfigService | RuntimeSourceStoreService | RuntimeSourceCatalogSyncService | SecretMaterialStorerService | SecretMaterialDeleterService | SecretMaterialUpdaterService | ScopeConfigStore | ScopeStateStore | SourceArtifactStore, never, never >; runtimeLocalScope: RuntimeLocalScopeState | null; }) => Effect.runPromise( provideOptionalRuntimeLocalScope( input.effect.pipe(Effect.provide(input.runtimeLayer)), input.runtimeLocalScope, ) as Effect.Effect<A, E, never>, ); const runScopeStorageEffect = <A, E, R>(input: { effect: Effect.Effect<A, E, R>; scopeStorageLayer: Layer.Layer< ScopeConfigStore | ScopeStateStore | SourceArtifactStore, never, never >; runtimeLocalScope: RuntimeLocalScopeState | null; }) => Effect.runPromise( provideOptionalRuntimeLocalScope( input.effect.pipe(Effect.provide(input.scopeStorageLayer)), input.runtimeLocalScope, ) as Effect.Effect<A, E, never>, ); export const createWorkspaceExecutorAdminToolMap = ( input: WorkspaceInternalToolContext, ): ToolMap => { const runtimeLayer = makeRuntimeLayer({ executorStateStore: input.executorStateStore, sourceStore: input.sourceStore, sourceCatalogSyncService: input.sourceCatalogSyncService, scopeConfigStore: input.scopeConfigStore, scopeStateStore: input.scopeStateStore, sourceArtifactStore: input.sourceArtifactStore, instanceConfigResolver: input.instanceConfigResolver, storeSecretMaterial: input.storeSecretMaterial, deleteSecretMaterial: input.deleteSecretMaterial, updateSecretMaterial: input.updateSecretMaterial, }); const scopeStorageLayer = makeScopeStorageLayer({ scopeConfigStore: input.scopeConfigStore, scopeStateStore: input.scopeStateStore, sourceArtifactStore: input.sourceArtifactStore, }); const metadata = { sourceKey: "executor", interaction: "auto" as const, }; return { "executor.local.installation.get": toTool({ tool: { description: "Get the active local executor installation account and workspace ids.", inputSchema: emptyInputSchema, outputSchema: localInstallationOutputSchema, execute: async () => ({ scopeId: input.scopeId, actorScopeId: input.actorScopeId, }), }, metadata, }), "executor.local.config.get": toTool({ tool: { description: "Get local instance config such as supported secret providers.", inputSchema: emptyInputSchema, outputSchema: instanceConfigOutputSchema, execute: () => Effect.runPromise(input.instanceConfigResolver()), }, metadata, }), "executor.secrets.list": toTool({ tool: { description: "List locally stored secrets and the sources linked to them.", inputSchema: emptyInputSchema, outputSchema: secretListOutputSchema, execute: () => runRuntimeEffect({ effect: listLocalSecrets(), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.secrets.create": toTool({ tool: { description: "Create a local secret without putting the raw value into source config.", inputSchema: createSecretInputSchema, outputSchema: Schema.standardSchemaV1(CreateSecretResultSchema), execute: (payload: CreateSecretPayload) => runRuntimeEffect({ effect: createLocalSecret(payload), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.secrets.update": toTool({ tool: { description: "Update a stored secret name and optionally rotate its value.", inputSchema: updateSecretInputSchema, outputSchema: Schema.standardSchemaV1(UpdateSecretResultSchema), execute: (payload: { secretId: string; payload: UpdateSecretPayload; }) => runRuntimeEffect({ effect: updateLocalSecret(payload), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.secrets.remove": toTool({ tool: { description: "Remove a stored local secret.", inputSchema: removeSecretInputSchema, outputSchema: Schema.standardSchemaV1(DeleteSecretResultSchema), execute: ({ secretId }: { secretId: string }) => runRuntimeEffect({ effect: deleteLocalSecret(secretId), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.sources.discover": toTool({ tool: { description: "Probe a URL and infer whether it looks like MCP, OpenAPI, GraphQL, or another supported source.", inputSchema: discoverSourceInputSchema, outputSchema: sourceDiscoveryOutputSchema, execute: (payload: { url: string; probeAuth?: unknown }) => Effect.runPromise( discoverSource({ url: payload.url, probeAuth: payload.probeAuth as never, }), ), }, metadata, }), "executor.sources.list": toTool({ tool: { description: "List sources connected in the current workspace.", inputSchema: emptyInputSchema, outputSchema: listSourcesOutputSchema, execute: () => runRuntimeEffect({ effect: listSources({ scopeId: input.scopeId, actorScopeId: input.actorScopeId as never, }), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.sources.get": toTool({ tool: { description: "Get one source by id.", inputSchema: getSourceInputSchema, outputSchema: sourceOutputSchema, execute: ({ sourceId }: { sourceId: string }) => runRuntimeEffect({ effect: getSource({ scopeId: input.scopeId, sourceId: sourceId as never, actorScopeId: input.actorScopeId as never, }), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.sources.update": toTool({ tool: { description: "Update a source definition in the current workspace.", inputSchema: updateSourceInputSchema, outputSchema: sourceOutputSchema, execute: (payload: { sourceId: string; payload: Record<string, unknown>; }) => runRuntimeEffect({ effect: updateSource({ scopeId: input.scopeId, sourceId: payload.sourceId as never, actorScopeId: input.actorScopeId as never, payload: payload.payload as never, }), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.sources.remove": toTool({ tool: { description: "Remove a source from the current workspace.", inputSchema: getSourceInputSchema, outputSchema: removeResultSchema, execute: ({ sourceId }: { sourceId: string }) => runRuntimeEffect({ effect: removeSource({ scopeId: input.scopeId, sourceId: sourceId as never, }), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.sources.inspect.get": toTool({ tool: { description: "Inspect the tool model for one connected source.", inputSchema: getSourceInputSchema, outputSchema: sourceInspectionOutputSchema, execute: ({ sourceId }: { sourceId: string }) => runRuntimeEffect({ effect: getSourceInspection({ scopeId: input.scopeId, sourceId: sourceId as never, }), runtimeLayer, runtimeLocalScope: input.runtimeLocalScope, }), }, metadata, }), "executor.sources.inspect.tool": toTool({ tool: { description: "Inspect one tool inside a connected source.", inputSchema: inspectToolInputSchema, outputSchema: sourceInspectionToolOutputSchema, execute: ({ sourceId,