History

disable admin tools

Rhys Sullivan committed 7 months ago

Commit ea023eb1 parent a5a74a11 file · +6 −993Browse files

Unified · Split

packages/platform/internal/src/tools/executor-admin.ts+6−993
@@ -1,998 +1,11 @@
1import { toTool, type ToolMap } from "@executor/codemode-core";1import type { ToolMap } from "@executor/codemode-core";
2import type { Executor } from "@executor/platform-sdk";2import type { Executor } from "@executor/platform-sdk";
3import {3import { type ScopeInternalToolContext as WorkspaceInternalToolContext } from "@executor/platform-sdk/runtime";
4 type ScopeId as AccountId,
5 LocalInstallationSchema,
6 LocalScopePolicySchema,
7 SourceDiscoveryResultSchema,
8 SourceIdSchema,
9 SourceInspectionDiscoverPayloadSchema,
10 SourceInspectionDiscoverResultSchema,
11 SourceInspectionSchema,
12 SourceInspectionToolDetailSchema,
13 SourceSchema,
14 type ScopeId as WorkspaceId,
15 ScopeOauthClientSchema,
16} from "@executor/platform-sdk/schema";
17import * as Effect from "effect/Effect";
18import * as Layer from "effect/Layer";
19import * as Schema from "effect/Schema";
20
21import {
22 ExecutorStateStore,
23 LocalInstanceConfigService,
24 SecretMaterialDeleterService,
25 SecretMaterialStorerService,
26 SecretMaterialUpdaterService,
27 type ExecutorStateStoreShape,
28 type ScopeInternalToolContext as WorkspaceInternalToolContext,
29 RuntimeSourceAuthService,
30 RuntimeSourceCatalogSyncService,
31 RuntimeSourceStore,
32 RuntimeSourceStoreService,
33} from "@executor/platform-sdk/runtime";
34import {
35 type RuntimeLocalScopeState,
36 provideOptionalRuntimeLocalScope,
37} from "../../../sdk/src/runtime/scope/runtime-context";
38import {
39 SourceArtifactStore,
40 type SourceArtifactStoreShape,
41 ScopeConfigStore,
42 type ScopeConfigStoreShape,
43 ScopeStateStore,
44 type ScopeStateStoreShape,
45 makeScopeStorageLayer,
46} from "../../../sdk/src/runtime/scope/storage";
47import {
48 CreateSecretPayloadSchema,
49 CreateSecretResultSchema,
50 type CreateSecretPayload,
51 DeleteSecretResultSchema,
52 InstanceConfigSchema,
53 SecretListItemSchema,
54 UpdateSecretPayloadSchema,
55 UpdateSecretResultSchema,
56 type UpdateSecretPayload,
57} from "@executor/platform-sdk/contracts";
58import {
59 createLocalSecret,
60 createPolicy,
61 deleteLocalSecret,
62 discoverSource,
63 discoverSourceInspectionTools,
64 getPolicy,
65 getSource,
66 getSourceInspection,
67 getSourceInspectionToolDetail,
68 listLocalSecrets,
69 listPolicies,
70 listSources,
71 removePolicy,
72 removeSource,
73 updateLocalSecret,
74 updatePolicy,
75 updateSource,
76} from "@executor/platform-sdk/operations";
77import {
78 CreatePolicyPayloadSchema,
79 type CreatePolicyPayload,
80 type UpdatePolicyPayload,
81 UpdatePolicyPayloadSchema,
82} from "@executor/platform-sdk/contracts";
83import {
84 CreateScopeOauthClientPayloadSchema,
85 DiscoverSourcePayloadSchema,
86 type CreateScopeOauthClientPayload as CreateWorkspaceOauthClientPayload,
87 UpdateSourcePayloadSchema,
88} from "@executor/platform-sdk/contracts";
89
90const emptyInputSchema = Schema.standardSchemaV1(Schema.Struct({}));
91const localInstallationOutputSchema = Schema.standardSchemaV1(
92 LocalInstallationSchema,
93);
94const instanceConfigOutputSchema =
95 Schema.standardSchemaV1(InstanceConfigSchema);
96const secretListOutputSchema = Schema.standardSchemaV1(
97 Schema.Array(SecretListItemSchema),
98);
99const createSecretInputSchema = Schema.standardSchemaV1(
100 CreateSecretPayloadSchema,
101);
102const updateSecretInputSchema = Schema.standardSchemaV1(
103 Schema.Struct({
104 secretId: Schema.String,
105 payload: UpdateSecretPayloadSchema,
106 }),
107);
108const removeSecretInputSchema = Schema.standardSchemaV1(
109 Schema.Struct({
110 secretId: Schema.String,
111 }),
112);
113const removeResultSchema = Schema.standardSchemaV1(
114 Schema.Struct({
115 removed: Schema.Boolean,
116 }),
117);
118const listSourcesOutputSchema = Schema.standardSchemaV1(
119 Schema.Array(SourceSchema),
120);
121const getSourceInputSchema = Schema.standardSchemaV1(
122 Schema.Struct({
123 sourceId: SourceIdSchema,
124 }),
125);
126const updateSourceInputSchema = Schema.standardSchemaV1(
127 Schema.Struct({
128 sourceId: SourceIdSchema,
129 payload: UpdateSourcePayloadSchema,
130 }),
131);
132const discoverSourceInputSchema = Schema.standardSchemaV1(
133 DiscoverSourcePayloadSchema,
134);
135const inspectToolInputSchema = Schema.standardSchemaV1(
136 Schema.Struct({
137 sourceId: SourceIdSchema,
138 toolPath: Schema.String,
139 }),
140);
141const inspectDiscoverInputSchema = Schema.standardSchemaV1(
142 Schema.Struct({
143 sourceId: SourceIdSchema,
144 payload: SourceInspectionDiscoverPayloadSchema,
145 }),
146);
147const listPoliciesOutputSchema = Schema.standardSchemaV1(
148 Schema.Array(LocalScopePolicySchema),
149);
150const policyIdInputSchema = Schema.standardSchemaV1(
151 Schema.Struct({
152 policyId: Schema.String,
153 }),
154);
155const createPolicyInputSchema = Schema.standardSchemaV1(
156 CreatePolicyPayloadSchema,
157);
158const updatePolicyInputSchema = Schema.standardSchemaV1(
159 Schema.Struct({
160 policyId: Schema.String,
161 payload: UpdatePolicyPayloadSchema,
162 }),
163);
164const workspaceOauthClientListInputSchema = Schema.standardSchemaV1(
165 Schema.Struct({
166 providerKey: Schema.String,
167 }),
168);
169const workspaceOauthClientListOutputSchema = Schema.standardSchemaV1(
170 Schema.Array(ScopeOauthClientSchema),
171);
172const createWorkspaceOauthClientInputSchema = Schema.standardSchemaV1(
173 CreateScopeOauthClientPayloadSchema,
174);
175const removeWorkspaceOauthClientInputSchema = Schema.standardSchemaV1(
176 Schema.Struct({
177 oauthClientId: Schema.String,
178 }),
179);
180const removeProviderGrantInputSchema = Schema.standardSchemaV1(
181 Schema.Struct({
182 grantId: Schema.String,
183 }),
184);
185const sourceOutputSchema = Schema.standardSchemaV1(SourceSchema);
186const sourceInspectionOutputSchema = Schema.standardSchemaV1(
187 SourceInspectionSchema,
188);
189const sourceInspectionToolOutputSchema = Schema.standardSchemaV1(
190 SourceInspectionToolDetailSchema,
191);
192const sourceInspectionDiscoverOutputSchema = Schema.standardSchemaV1(
193 SourceInspectionDiscoverResultSchema,
194);
195const sourceDiscoveryOutputSchema = Schema.standardSchemaV1(
196 SourceDiscoveryResultSchema,
197);
198const localScopePolicyOutputSchema = Schema.standardSchemaV1(
199 LocalScopePolicySchema,
200);
201
202const makeRuntimeLayer = (input: {
203 executorStateStore: ExecutorStateStoreShape;
204 sourceStore: RuntimeSourceStore;
205 sourceCatalogSyncService: Effect.Effect.Success<
206 typeof RuntimeSourceCatalogSyncService
207 >;
208 scopeConfigStore: ScopeConfigStoreShape;
209 scopeStateStore: ScopeStateStoreShape;
210 sourceArtifactStore: SourceArtifactStoreShape;
211 instanceConfigResolver: WorkspaceInternalToolContext["instanceConfigResolver"];
212 storeSecretMaterial: WorkspaceInternalToolContext["storeSecretMaterial"];
213 deleteSecretMaterial: WorkspaceInternalToolContext["deleteSecretMaterial"];
214 updateSecretMaterial: WorkspaceInternalToolContext["updateSecretMaterial"];
215}) =>
216 Layer.mergeAll(
217 Layer.succeed(ExecutorStateStore, input.executorStateStore),
218 Layer.succeed(RuntimeSourceStoreService, input.sourceStore),
219 Layer.succeed(
220 RuntimeSourceCatalogSyncService,
221 input.sourceCatalogSyncService,
222 ),
223 Layer.succeed(LocalInstanceConfigService, input.instanceConfigResolver),
224 Layer.succeed(SecretMaterialStorerService, input.storeSecretMaterial),
225 Layer.succeed(SecretMaterialDeleterService, input.deleteSecretMaterial),
226 Layer.succeed(SecretMaterialUpdaterService, input.updateSecretMaterial),
227 makeScopeStorageLayer({
228 scopeConfigStore: input.scopeConfigStore,
229 scopeStateStore: input.scopeStateStore,
230 sourceArtifactStore: input.sourceArtifactStore,
231 }),
232 );
233
234const runRuntimeEffect = <A, E, R>(input: {
235 effect: Effect.Effect<A, E, R>;
236 runtimeLayer: Layer.Layer<
237 | ExecutorStateStore
238 | LocalInstanceConfigService
239 | RuntimeSourceStoreService
240 | RuntimeSourceCatalogSyncService
241 | SecretMaterialStorerService
242 | SecretMaterialDeleterService
243 | SecretMaterialUpdaterService
244 | ScopeConfigStore
245 | ScopeStateStore
246 | SourceArtifactStore,
247 never,
248 never
249 >;
250 runtimeLocalScope: RuntimeLocalScopeState | null;
251}) =>
252 Effect.runPromise(
253 provideOptionalRuntimeLocalScope(
254 input.effect.pipe(Effect.provide(input.runtimeLayer)),
255 input.runtimeLocalScope,
256 ) as Effect.Effect<A, E, never>,
257 );
258
259const runScopeStorageEffect = <A, E, R>(input: {
260 effect: Effect.Effect<A, E, R>;
261 scopeStorageLayer: Layer.Layer<
262 ScopeConfigStore | ScopeStateStore | SourceArtifactStore,
263 never,
264 never
265 >;
266 runtimeLocalScope: RuntimeLocalScopeState | null;
267}) =>
268 Effect.runPromise(
269 provideOptionalRuntimeLocalScope(
270 input.effect.pipe(Effect.provide(input.scopeStorageLayer)),
271 input.runtimeLocalScope,
272 ) as Effect.Effect<A, E, never>,
273 );
274 4
275export const createWorkspaceExecutorAdminToolMap = (5export const createWorkspaceExecutorAdminToolMap = (
276 input: WorkspaceInternalToolContext,6 _input: WorkspaceInternalToolContext,
277): ToolMap => {7): ToolMap => ({});
278 const runtimeLayer = makeRuntimeLayer({
279 executorStateStore: input.executorStateStore,
280 sourceStore: input.sourceStore,
281 sourceCatalogSyncService: input.sourceCatalogSyncService,
282 scopeConfigStore: input.scopeConfigStore,
283 scopeStateStore: input.scopeStateStore,
284 sourceArtifactStore: input.sourceArtifactStore,
285 instanceConfigResolver: input.instanceConfigResolver,
286 storeSecretMaterial: input.storeSecretMaterial,
287 deleteSecretMaterial: input.deleteSecretMaterial,
288 updateSecretMaterial: input.updateSecretMaterial,
289 });
290 const scopeStorageLayer = makeScopeStorageLayer({
291 scopeConfigStore: input.scopeConfigStore,
292 scopeStateStore: input.scopeStateStore,
293 sourceArtifactStore: input.sourceArtifactStore,
294 });
295
296 const metadata = {
297 sourceKey: "executor",
298 interaction: "auto" as const,
299 };
300 8
301 return {9export const createExecutorAdminToolMap = (_input: {
302 "executor.local.installation.get": toTool({
303 tool: {
304 description:
305 "Get the active local executor installation account and workspace ids.",
306 inputSchema: emptyInputSchema,
307 outputSchema: localInstallationOutputSchema,
308 execute: async () => ({
309 scopeId: input.scopeId,
310 actorScopeId: input.actorScopeId,
311 }),
312 },
313 metadata,
314 }),
315 "executor.local.config.get": toTool({
316 tool: {
317 description:
318 "Get local instance config such as supported secret providers.",
319 inputSchema: emptyInputSchema,
320 outputSchema: instanceConfigOutputSchema,
321 execute: () => Effect.runPromise(input.instanceConfigResolver()),
322 },
323 metadata,
324 }),
325 "executor.secrets.list": toTool({
326 tool: {
327 description:
328 "List locally stored secrets and the sources linked to them.",
329 inputSchema: emptyInputSchema,
330 outputSchema: secretListOutputSchema,
331 execute: () =>
332 runRuntimeEffect({
333 effect: listLocalSecrets(),
334 runtimeLayer,
335 runtimeLocalScope: input.runtimeLocalScope,
336 }),
337 },
338 metadata,
339 }),
340 "executor.secrets.create": toTool({
341 tool: {
342 description:
343 "Create a local secret without putting the raw value into source config.",
344 inputSchema: createSecretInputSchema,
345 outputSchema: Schema.standardSchemaV1(CreateSecretResultSchema),
346 execute: (payload: CreateSecretPayload) =>
347 runRuntimeEffect({
348 effect: createLocalSecret(payload),
349 runtimeLayer,
350 runtimeLocalScope: input.runtimeLocalScope,
351 }),
352 },
353 metadata,
354 }),
355 "executor.secrets.update": toTool({
356 tool: {
357 description:
358 "Update a stored secret name and optionally rotate its value.",
359 inputSchema: updateSecretInputSchema,
360 outputSchema: Schema.standardSchemaV1(UpdateSecretResultSchema),
361 execute: (payload: {
362 secretId: string;
363 payload: UpdateSecretPayload;
364 }) =>
365 runRuntimeEffect({
366 effect: updateLocalSecret(payload),
367 runtimeLayer,
368 runtimeLocalScope: input.runtimeLocalScope,
369 }),
370 },
371 metadata,
372 }),
373 "executor.secrets.remove": toTool({
374 tool: {
375 description: "Remove a stored local secret.",
376 inputSchema: removeSecretInputSchema,
377 outputSchema: Schema.standardSchemaV1(DeleteSecretResultSchema),
378 execute: ({ secretId }: { secretId: string }) =>
379 runRuntimeEffect({
380 effect: deleteLocalSecret(secretId),
381 runtimeLayer,
382 runtimeLocalScope: input.runtimeLocalScope,
383 }),
384 },
385 metadata,
386 }),
387 "executor.sources.discover": toTool({
388 tool: {
389 description:
390 "Probe a URL and infer whether it looks like MCP, OpenAPI, GraphQL, or another supported source.",
391 inputSchema: discoverSourceInputSchema,
392 outputSchema: sourceDiscoveryOutputSchema,
393 execute: (payload: { url: string; probeAuth?: unknown }) =>
394 Effect.runPromise(
395 discoverSource({
396 url: payload.url,
397 probeAuth: payload.probeAuth as never,
398 }),
399 ),
400 },
401 metadata,
402 }),
403 "executor.sources.list": toTool({
404 tool: {
405 description: "List sources connected in the current workspace.",
406 inputSchema: emptyInputSchema,
407 outputSchema: listSourcesOutputSchema,
408 execute: () =>
409 runRuntimeEffect({
410 effect: listSources({
411 scopeId: input.scopeId,
412 actorScopeId: input.actorScopeId as never,
413 }),
414 runtimeLayer,
415 runtimeLocalScope: input.runtimeLocalScope,
416 }),
417 },
418 metadata,
419 }),
420 "executor.sources.get": toTool({
421 tool: {
422 description: "Get one source by id.",
423 inputSchema: getSourceInputSchema,
424 outputSchema: sourceOutputSchema,
425 execute: ({ sourceId }: { sourceId: string }) =>
426 runRuntimeEffect({
427 effect: getSource({
428 scopeId: input.scopeId,
429 sourceId: sourceId as never,
430 actorScopeId: input.actorScopeId as never,
431 }),
432 runtimeLayer,
433 runtimeLocalScope: input.runtimeLocalScope,
434 }),
435 },
436 metadata,
437 }),
438 "executor.sources.update": toTool({
439 tool: {
440 description: "Update a source definition in the current workspace.",
441 inputSchema: updateSourceInputSchema,
442 outputSchema: sourceOutputSchema,
443 execute: (payload: {
444 sourceId: string;
445 payload: Record<string, unknown>;
446 }) =>
447 runRuntimeEffect({
448 effect: updateSource({
449 scopeId: input.scopeId,
450 sourceId: payload.sourceId as never,
451 actorScopeId: input.actorScopeId as never,
452 payload: payload.payload as never,
453 }),
454 runtimeLayer,
455 runtimeLocalScope: input.runtimeLocalScope,
456 }),
457 },
458 metadata,
459 }),
460 "executor.sources.remove": toTool({
461 tool: {
462 description: "Remove a source from the current workspace.",
463 inputSchema: getSourceInputSchema,
464 outputSchema: removeResultSchema,
465 execute: ({ sourceId }: { sourceId: string }) =>
466 runRuntimeEffect({
467 effect: removeSource({
468 scopeId: input.scopeId,
469 sourceId: sourceId as never,
470 }),
471 runtimeLayer,
472 runtimeLocalScope: input.runtimeLocalScope,
473 }),
474 },
475 metadata,
476 }),
477 "executor.sources.inspect.get": toTool({
478 tool: {
479 description: "Inspect the tool model for one connected source.",
480 inputSchema: getSourceInputSchema,
481 outputSchema: sourceInspectionOutputSchema,
482 execute: ({ sourceId }: { sourceId: string }) =>
483 runRuntimeEffect({
484 effect: getSourceInspection({
485 scopeId: input.scopeId,
486 sourceId: sourceId as never,
487 }),
488 runtimeLayer,
489 runtimeLocalScope: input.runtimeLocalScope,
490 }),
491 },
492 metadata,
493 }),
494 "executor.sources.inspect.tool": toTool({
495 tool: {
496 description: "Inspect one tool inside a connected source.",
497 inputSchema: inspectToolInputSchema,
498 outputSchema: sourceInspectionToolOutputSchema,
499 execute: ({
500 sourceId,
501 toolPath,
502 }: {
503 sourceId: string;
504 toolPath: string;
505 }) =>
506 runRuntimeEffect({
507 effect: getSourceInspectionToolDetail({
508 scopeId: input.scopeId,
509 sourceId: sourceId as never,
510 toolPath,
511 }),
512 runtimeLayer,
513 runtimeLocalScope: input.runtimeLocalScope,
514 }),
515 },
516 metadata,
517 }),
518 "executor.sources.inspect.discover": toTool({
519 tool: {
520 description: "Search within a single source's inspected tools.",
521 inputSchema: inspectDiscoverInputSchema,
522 outputSchema: sourceInspectionDiscoverOutputSchema,
523 execute: ({
524 sourceId,
525 payload,
526 }: {
527 sourceId: string;
528 payload: { query: string; limit?: number };
529 }) =>
530 runRuntimeEffect({
531 effect: discoverSourceInspectionTools({
532 scopeId: input.scopeId,
533 sourceId: sourceId as never,
534 payload: payload as never,
535 }),
536 runtimeLayer,
537 runtimeLocalScope: input.runtimeLocalScope,
538 }),
539 },
540 metadata,
541 }),
542 "executor.sources.oauthClients.list": toTool({
543 tool: {
544 description: "List workspace OAuth clients for a provider key.",
545 inputSchema: workspaceOauthClientListInputSchema,
546 outputSchema: workspaceOauthClientListOutputSchema,
547 execute: ({ providerKey }: { providerKey: string }) =>
548 runScopeStorageEffect({
549 effect: input.sourceAuthService.listScopeOauthClients({
550 scopeId: input.scopeId,
551 providerKey,
552 }),
553 scopeStorageLayer,
554 runtimeLocalScope: input.runtimeLocalScope,
555 }),
556 },
557 metadata,
558 }),
559 "executor.sources.oauthClients.create": toTool({
560 tool: {
561 description:
562 "Create a workspace OAuth client used for shared provider auth flows.",
563 inputSchema: createWorkspaceOauthClientInputSchema,
564 outputSchema: Schema.standardSchemaV1(ScopeOauthClientSchema),
565 execute: (payload: CreateWorkspaceOauthClientPayload) =>
566 runScopeStorageEffect({
567 effect: input.sourceAuthService.createScopeOauthClient({
568 scopeId: input.scopeId,
569 providerKey: payload.providerKey,
570 label: payload.label,
571 oauthClient: payload.oauthClient,
572 }),
573 scopeStorageLayer,
574 runtimeLocalScope: input.runtimeLocalScope,
575 }),
576 },
577 metadata,
578 }),
579 "executor.sources.oauthClients.remove": toTool({
580 tool: {
581 description: "Remove a workspace OAuth client.",
582 inputSchema: removeWorkspaceOauthClientInputSchema,
583 outputSchema: removeResultSchema,
584 execute: ({ oauthClientId }: { oauthClientId: string }) =>
585 runScopeStorageEffect({
586 effect: input.sourceAuthService
587 .removeScopeOauthClient({
588 scopeId: input.scopeId,
589 oauthClientId: oauthClientId as never,
590 })
591 .pipe(Effect.map((removed) => ({ removed }))),
592 scopeStorageLayer,
593 runtimeLocalScope: input.runtimeLocalScope,
594 }),
595 },
596 metadata,
597 }),
598 "executor.sources.providerGrants.remove": toTool({
599 tool: {
600 description:
601 "Revoke a shared provider grant reference from the local workspace.",
602 inputSchema: removeProviderGrantInputSchema,
603 outputSchema: removeResultSchema,
604 execute: ({ grantId }: { grantId: string }) =>
605 runScopeStorageEffect({
606 effect: input.sourceAuthService
607 .removeProviderAuthGrant({
608 scopeId: input.scopeId,
609 grantId: grantId as never,
610 })
611 .pipe(Effect.map((removed) => ({ removed }))),
612 scopeStorageLayer,
613 runtimeLocalScope: input.runtimeLocalScope,
614 }),
615 },
616 metadata,
617 }),
618 "executor.policies.list": toTool({
619 tool: {
620 description: "List local workspace policies.",
621 inputSchema: emptyInputSchema,
622 outputSchema: listPoliciesOutputSchema,
623 execute: () =>
624 runRuntimeEffect({
625 effect: listPolicies(input.scopeId),
626 runtimeLayer,
627 runtimeLocalScope: input.runtimeLocalScope,
628 }),
629 },
630 metadata,
631 }),
632 "executor.policies.create": toTool({
633 tool: {
634 description: "Create a local workspace policy.",
635 inputSchema: createPolicyInputSchema,
636 outputSchema: localScopePolicyOutputSchema,
637 execute: (payload: CreatePolicyPayload) =>
638 runRuntimeEffect({
639 effect: createPolicy({
640 scopeId: input.scopeId,
641 payload,
642 }),
643 runtimeLayer,
644 runtimeLocalScope: input.runtimeLocalScope,
645 }),
646 },
647 metadata,
648 }),
649 "executor.policies.get": toTool({
650 tool: {
651 description: "Get one local workspace policy by id.",
652 inputSchema: policyIdInputSchema,
653 outputSchema: localScopePolicyOutputSchema,
654 execute: ({ policyId }: { policyId: string }) =>
655 runRuntimeEffect({
656 effect: getPolicy({
657 scopeId: input.scopeId,
658 policyId: policyId as never,
659 }),
660 runtimeLayer,
661 runtimeLocalScope: input.runtimeLocalScope,
662 }),
663 },
664 metadata,
665 }),
666 "executor.policies.update": toTool({
667 tool: {
668 description: "Update a local workspace policy.",
669 inputSchema: updatePolicyInputSchema,
670 outputSchema: localScopePolicyOutputSchema,
671 execute: ({
672 policyId,
673 payload,
674 }: {
675 policyId: string;
676 payload: UpdatePolicyPayload;
677 }) =>
678 runRuntimeEffect({
679 effect: updatePolicy({
680 scopeId: input.scopeId,
681 policyId: policyId as never,
682 payload,
683 }),
684 runtimeLayer,
685 runtimeLocalScope: input.runtimeLocalScope,
686 }),
687 },
688 metadata,
689 }),
690 "executor.policies.remove": toTool({
691 tool: {
692 description: "Remove a local workspace policy.",
693 inputSchema: policyIdInputSchema,
694 outputSchema: removeResultSchema,
695 execute: ({ policyId }: { policyId: string }) =>
696 runRuntimeEffect({
697 effect: removePolicy({
698 scopeId: input.scopeId,
699 policyId: policyId as never,
700 }),
701 runtimeLayer,
702 runtimeLocalScope: input.runtimeLocalScope,
703 }),
704 },
705 metadata,
706 }),
707 };
708};
709
710export const createExecutorAdminToolMap = (input: {
711 executor: Executor;10 executor: Executor;
712}): ToolMap => {11}): ToolMap => ({});
713 const metadata = {
714 sourceKey: "executor",
715 interaction: "auto" as const,
716 };
717
718 return {
719 "executor.local.installation.get": toTool({
720 tool: {
721 description:
722 "Get the active local executor installation account and workspace ids.",
723 inputSchema: emptyInputSchema,
724 outputSchema: localInstallationOutputSchema,
725 execute: () => Promise.resolve(input.executor.installation),
726 },
727 metadata,
728 }),
729 "executor.local.config.get": toTool({
730 tool: {
731 description:
732 "Get local instance config such as supported secret providers.",
733 inputSchema: emptyInputSchema,
734 outputSchema: instanceConfigOutputSchema,
735 execute: () => input.executor.local.config(),
736 },
737 metadata,
738 }),
739 "executor.secrets.list": toTool({
740 tool: {
741 description:
742 "List locally stored secrets and the sources linked to them.",
743 inputSchema: emptyInputSchema,
744 outputSchema: secretListOutputSchema,
745 execute: () => input.executor.secrets.list(),
746 },
747 metadata,
748 }),
749 "executor.secrets.create": toTool({
750 tool: {
751 description:
752 "Create a local secret without putting the raw value into source config.",
753 inputSchema: createSecretInputSchema,
754 outputSchema: Schema.standardSchemaV1(CreateSecretResultSchema),
755 execute: (payload: CreateSecretPayload) =>
756 input.executor.secrets.create(payload),
757 },
758 metadata,
759 }),
760 "executor.secrets.update": toTool({
761 tool: {
762 description:
763 "Update a stored secret name and optionally rotate its value.",
764 inputSchema: updateSecretInputSchema,
765 outputSchema: Schema.standardSchemaV1(UpdateSecretResultSchema),
766 execute: (payload: {
767 secretId: string;
768 payload: UpdateSecretPayload;
769 }) => input.executor.secrets.update(payload),
770 },
771 metadata,
772 }),
773 "executor.secrets.remove": toTool({
774 tool: {
775 description: "Remove a stored local secret.",
776 inputSchema: removeSecretInputSchema,
777 outputSchema: Schema.standardSchemaV1(DeleteSecretResultSchema),
778 execute: ({ secretId }: { secretId: string }) =>
779 input.executor.secrets.remove(secretId),
780 },
781 metadata,
782 }),
783 "executor.sources.discover": toTool({
784 tool: {
785 description:
786 "Probe a URL and infer whether it looks like MCP, OpenAPI, GraphQL, or another supported source.",
787 inputSchema: discoverSourceInputSchema,
788 outputSchema: sourceDiscoveryOutputSchema,
789 execute: (payload: { url: string; probeAuth?: unknown }) =>
790 input.executor.sources.discover({
791 url: payload.url,
792 probeAuth: payload.probeAuth as never,
793 }),
794 },
795 metadata,
796 }),
797 "executor.sources.list": toTool({
798 tool: {
799 description: "List sources connected in the current workspace.",
800 inputSchema: emptyInputSchema,
801 outputSchema: listSourcesOutputSchema,
802 execute: () => input.executor.sources.list(),
803 },
804 metadata,
805 }),
806 "executor.sources.get": toTool({
807 tool: {
808 description: "Get one source by id.",
809 inputSchema: getSourceInputSchema,
810 outputSchema: sourceOutputSchema,
811 execute: ({ sourceId }: { sourceId: string }) =>
812 input.executor.sources.get(sourceId as never),
813 },
814 metadata,
815 }),
816 "executor.sources.update": toTool({
817 tool: {
818 description: "Update a source definition in the current workspace.",
819 inputSchema: updateSourceInputSchema,
820 outputSchema: sourceOutputSchema,
821 execute: (payload: {
822 sourceId: string;
823 payload: Record<string, unknown>;
824 }) =>
825 input.executor.sources.update(
826 payload.sourceId as never,
827 payload.payload as never,
828 ),
829 },
830 metadata,
831 }),
832 "executor.sources.remove": toTool({
833 tool: {
834 description: "Remove a source from the current workspace.",
835 inputSchema: getSourceInputSchema,
836 outputSchema: removeResultSchema,
837 execute: async ({ sourceId }: { sourceId: string }) => ({
838 removed: await input.executor.sources.remove(sourceId as never),
839 }),
840 },
841 metadata,
842 }),
843 "executor.sources.inspect.get": toTool({
844 tool: {
845 description: "Inspect the tool model for one connected source.",
846 inputSchema: getSourceInputSchema,
847 outputSchema: sourceInspectionOutputSchema,
848 execute: ({ sourceId }: { sourceId: string }) =>
849 input.executor.sources.inspection.get(sourceId as never),
850 },
851 metadata,
852 }),
853 "executor.sources.inspect.tool": toTool({
854 tool: {
855 description: "Inspect one tool inside a connected source.",
856 inputSchema: inspectToolInputSchema,
857 outputSchema: sourceInspectionToolOutputSchema,
858 execute: ({
859 sourceId,
860 toolPath,
861 }: {
862 sourceId: string;
863 toolPath: string;
864 }) =>
865 input.executor.sources.inspection.tool({
866 sourceId: sourceId as never,
867 toolPath,
868 }),
869 },
870 metadata,
871 }),
872 "executor.sources.inspect.discover": toTool({
873 tool: {
874 description: "Search within a single source's inspected tools.",
875 inputSchema: inspectDiscoverInputSchema,
876 outputSchema: sourceInspectionDiscoverOutputSchema,
877 execute: ({
878 sourceId,
879 payload,
880 }: {
881 sourceId: string;
882 payload: { query: string; limit?: number };
883 }) =>
884 input.executor.sources.inspection.discover({
885 sourceId: sourceId as never,
886 payload: payload as never,
887 }),
888 },
889 metadata,
890 }),
891 "executor.sources.oauthClients.list": toTool({
892 tool: {
893 description: "List stored workspace OAuth clients for one provider.",
894 inputSchema: workspaceOauthClientListInputSchema,
895 outputSchema: workspaceOauthClientListOutputSchema,
896 execute: ({ providerKey }: { providerKey: string }) =>
897 input.executor.sources.oauthClients.list(providerKey),
898 },
899 metadata,
900 }),
901 "executor.sources.oauthClients.create": toTool({
902 tool: {
903 description:
904 "Create a workspace OAuth client for a provider-backed source flow.",
905 inputSchema: createWorkspaceOauthClientInputSchema,
906 outputSchema: Schema.standardSchemaV1(ScopeOauthClientSchema),
907 execute: (payload: CreateWorkspaceOauthClientPayload) =>
908 input.executor.sources.oauthClients.create(payload),
909 },
910 metadata,
911 }),
912 "executor.sources.oauthClients.remove": toTool({
913 tool: {
914 description: "Remove a stored workspace OAuth client.",
915 inputSchema: removeWorkspaceOauthClientInputSchema,
916 outputSchema: removeResultSchema,
917 execute: async ({
918 oauthClientId,
919 }: {
920 oauthClientId: string;
921 }) => ({
922 removed: await input.executor.sources.oauthClients.remove(
923 oauthClientId as never,
924 ),
925 }),
926 },
927 metadata,
928 }),
929 "executor.sources.providerGrants.remove": toTool({
930 tool: {
931 description: "Remove one stored provider auth grant.",
932 inputSchema: removeProviderGrantInputSchema,
933 outputSchema: removeResultSchema,
934 execute: async ({ grantId }: { grantId: string }) => ({
935 removed: await input.executor.sources.providerGrants.remove(
936 grantId as never,
937 ),
938 }),
939 },
940 metadata,
941 }),
942 "executor.policies.list": toTool({
943 tool: {
944 description: "List local workspace policies.",
945 inputSchema: emptyInputSchema,
946 outputSchema: listPoliciesOutputSchema,
947 execute: () => input.executor.policies.list(),
948 },
949 metadata,
950 }),
951 "executor.policies.create": toTool({
952 tool: {
953 description: "Create a local workspace policy.",
954 inputSchema: createPolicyInputSchema,
955 outputSchema: localScopePolicyOutputSchema,
956 execute: (payload: CreatePolicyPayload) =>
957 input.executor.policies.create(payload),
958 },
959 metadata,
960 }),
961 "executor.policies.get": toTool({
962 tool: {
963 description: "Get one local workspace policy by id.",
964 inputSchema: policyIdInputSchema,
965 outputSchema: localScopePolicyOutputSchema,
966 execute: ({ policyId }: { policyId: string }) =>
967 input.executor.policies.get(policyId),
968 },
969 metadata,
970 }),
971 "executor.policies.update": toTool({
972 tool: {
973 description: "Update a local workspace policy.",
974 inputSchema: updatePolicyInputSchema,
975 outputSchema: localScopePolicyOutputSchema,
976 execute: ({
977 policyId,
978 payload,
979 }: {
980 policyId: string;
981 payload: UpdatePolicyPayload;
982 }) => input.executor.policies.update(policyId, payload),
983 },
984 metadata,
985 }),
986 "executor.policies.remove": toTool({
987 tool: {
988 description: "Remove a local workspace policy.",
989 inputSchema: policyIdInputSchema,
990 outputSchema: removeResultSchema,
991 execute: async ({ policyId }: { policyId: string }) => ({
992 removed: await input.executor.policies.remove(policyId),
993 }),
994 },
995 metadata,
996 }),
997 };
998};