* Track MCP tool executions in Autumn billing MCP tool calls bypassed the execution-usage tracking wrapper because the session DO built the engine implicitly inside createExecutorMcpServer. Build the engine in the DO, wrap it with withExecutionUsageTracking, and pass it through so executions increment the Autumn `executions` feature. * fix lockfile
Unified · Split
| @@ -10,14 +10,18 @@ import { drizzle } from "drizzle-orm/postgres-js"; · 9 unmodified lines | ||
| 10 | 10 | import postgres from "postgres"; |
| 11 | 11 | |
| 12 | 12 | import { createExecutorMcpServer } from "@executor/host-mcp"; |
| 13 | +import { createExecutionEngine } from "@executor/execution"; | |
| 13 | 14 | import { makeDynamicWorkerExecutor } from "@executor/runtime-dynamic-worker"; |
| 14 | 15 | import type { DrizzleDb } from "@executor/storage-postgres"; |
| 15 | 16 | import * as sharedSchema from "@executor/storage-postgres/schema"; |
| 16 | 17 | |
| 18 | +import { makeTrackExecutionUsage } from "./api/autumn"; | |
| 19 | +import { withExecutionUsageTracking } from "./api/execution-usage"; | |
| 17 | 20 | import { UserStoreService } from "./auth/context"; |
| 18 | 21 | import { resolveOrganization } from "./auth/resolve-organization"; |
| 19 | 22 | import { WorkOSAuth } from "./auth/workos"; |
| 20 | 23 | import { server } from "./env"; |
| 24 | +import { AutumnService } from "./services/autumn"; | |
| 21 | 25 | import { createOrgExecutor } from "./services/executor"; |
| 22 | 26 | import { DbService } from "./services/db"; |
| 23 | 27 | import * as cloudSchema from "./services/schema"; |
| @@ -107,7 +111,12 @@ export class McpSessionDO extends DurableObject { · 83 unmodified lines | ||
| 107 | 111 | |
| 108 | 112 | const DbLive = Layer.succeed(DbService, this.dbHandle.db); |
| 109 | 113 | const UserStoreLive = UserStoreService.Live.pipe(Layer.provide(DbLive)); |
| 110 | − const Services = Layer.mergeAll(DbLive, UserStoreLive, WorkOSAuth.Default); | |
| 114 | + const Services = Layer.mergeAll( | |
| 115 | + DbLive, | |
| 116 | + UserStoreLive, | |
| 117 | + WorkOSAuth.Default, | |
| 118 | + AutumnService.Default, | |
| 119 | + ); | |
| 111 | 120 | |
| 112 | 121 | const program = Effect.gen(function* () { |
| 113 | 122 | const org = yield* resolveOrganization(token.organizationId); |
| @@ -116,7 +125,13 @@ export class McpSessionDO extends DurableObject { · 2 unmodified lines | ||
| 116 | 125 | |
| 117 | 126 | const executor = yield* createOrgExecutor(org.id, org.name); |
| 118 | 127 | const codeExecutor = makeDynamicWorkerExecutor({ loader: env.LOADER }); |
| 119 | − return yield* Effect.promise(() => createExecutorMcpServer({ executor, codeExecutor })); | |
| 128 | + const autumn = yield* AutumnService; | |
| 129 | + const engine = withExecutionUsageTracking( | |
| 130 | + org.id, | |
| 131 | + createExecutionEngine({ executor, codeExecutor }), | |
| 132 | + makeTrackExecutionUsage(autumn), | |
| 133 | + ); | |
| 134 | + return yield* Effect.promise(() => createExecutorMcpServer({ engine })); | |
| 120 | 135 | }).pipe(Effect.provide(Services)); |
| 121 | 136 | |
| 122 | 137 | this.mcpServer = await Effect.runPromise(program); |
| @@ -324,6 +324,7 @@ · 323 unmodified lines | ||
| 324 | 324 | "name": "@executor/codemode-core", |
| 325 | 325 | "version": "1.4.3", |
| 326 | 326 | "dependencies": { |
| 327 | + "@babel/parser": "^7.29.2", | |
| 327 | 328 | "@standard-schema/spec": "^1.0.0", |
| 328 | 329 | "ajv": "^8.17.1", |
| 329 | 330 | "ajv-formats": "^3.0.1", |