(options?: AppsPluginOptions)
| 548 | } |
| 549 | |
| 550 | export const makeAppsPlugin = (options?: AppsPluginOptions) => |
| 551 | definePlugin(() => ({ |
| 552 | id: "apps", |
| 553 | packageName: "@executor-js/plugin-apps", |
| 554 | clientConfig: { sourceKinds: options?.sourceKinds ?? ["git", "local-directory"] }, |
| 555 | pluginStorage: { |
| 556 | [descriptorCollection.name]: descriptorCollection, |
| 557 | [toolCollection.name]: toolCollection, |
| 558 | [sourceCollection.name]: sourceCollection, |
| 559 | }, |
| 560 | storage: ({ blobs, pluginStorage }) => makeAppsStore({ blobs, pluginStorage }), |
| 561 | extension: (ctx: PluginCtx<AppsStore>) => makeAppsExtension(ctx, options), |
| 562 | resolveTools: ({ storage, connection }) => |
| 563 | storage.listActiveTools().pipe( |
| 564 | Effect.map((tools) => ({ |
| 565 | tools: tools |
| 566 | .filter((tool) => tool.app === String(connection.integration)) |
| 567 | .map( |
| 568 | (tool): ToolDef => ({ |
| 569 | name: ToolName.make(tool.name), |
| 570 | description: tool.description, |
| 571 | inputSchema: tool.inputSchema, |
| 572 | outputSchema: tool.outputSchema, |
| 573 | annotations: { |
| 574 | ...(tool.annotations?.requiresApproval !== undefined |
| 575 | ? { requiresApproval: tool.annotations.requiresApproval } |
| 576 | : {}), |
| 577 | ...(tool.annotations?.readOnly === true ? { requiresApproval: false } : {}), |
| 578 | }, |
| 579 | }), |
| 580 | ), |
| 581 | })), |
| 582 | ), |
| 583 | projectToolSchema: ({ ctx, toolRow, inputSchema, outputSchema }) => |
| 584 | projectAppsToolSchema( |
| 585 | ctx, |
| 586 | String(toolRow.integration), |
| 587 | String(toolRow.name), |
| 588 | inputSchema, |
| 589 | outputSchema, |
| 590 | ), |
| 591 | validateToolArgs: ({ ctx, toolRow, args }) => |
| 592 | Effect.gen(function* () { |
| 593 | const tool = yield* ctx.storage.getToolForApp( |
| 594 | String(toolRow.integration), |
| 595 | String(toolRow.name), |
| 596 | ); |
| 597 | if (!tool) return; |
| 598 | const resolver = makePluginCtxAppsResolver({ ctx }); |
| 599 | yield* resolveIntegrationBindings(tool.integrations, args, resolver); |
| 600 | }), |
| 601 | invokeTool: ({ ctx, toolRow, args, invokeOptions }) => |
| 602 | Effect.gen(function* () { |
| 603 | const tool = yield* ctx.storage.getToolForApp( |
| 604 | String(toolRow.integration), |
| 605 | String(toolRow.name), |
| 606 | ); |
| 607 | if (!tool) { |
no test coverage detected