feat(billing): bill Cursor executor usage via stream-json token parsing
Memind CI / Test, build, and release guards (push) Failing after 14m36s
Memind CI / Test, build, and release guards (push) Failing after 14m36s
Parse Cursor CLI usage from stream-json output and charge through billSessionUsage so subscription quota is consumed first and wallet overage applies when needed. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,6 +3,10 @@ import { EventEmitter } from 'node:events';
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { buildCursorExecutorLaunchPlan } from './cursor-agent-launch.mjs';
|
||||
import {
|
||||
extractCursorAgentDisplayText,
|
||||
parseCursorAgentUsage,
|
||||
} from './cursor-agent-usage.mjs';
|
||||
import { resolveExecutorDisplayLabel } from './executor-display-label.mjs';
|
||||
|
||||
const BASE_CODE_EXECUTORS = ['aider', 'openhands'];
|
||||
@@ -308,6 +312,10 @@ export function createToolGateway({
|
||||
child.on('exit', (code, signal) => {
|
||||
cleanup();
|
||||
if (code === 0) {
|
||||
const usage = executor === 'cursor' ? parseCursorAgentUsage(stdout) : null;
|
||||
const displayStdout = executor === 'cursor'
|
||||
? extractCursorAgentDisplayText(stdout)
|
||||
: '';
|
||||
resolve({
|
||||
ok: true,
|
||||
executor,
|
||||
@@ -319,6 +327,8 @@ export function createToolGateway({
|
||||
exitCode: code,
|
||||
signal: signal ?? null,
|
||||
stdout,
|
||||
displayStdout: displayStdout || undefined,
|
||||
usage: usage ?? undefined,
|
||||
stderr,
|
||||
});
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user