feat(cursor): wire executor through portal, admin, and wechat routes
Register cursor in LLM executor bindings, route page/code tasks through cursor runtime selection, and bootstrap wechat cursor policy services. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -57,6 +57,17 @@ async function columnExists(pool, table, column) {
|
||||
return rows.length > 0;
|
||||
}
|
||||
|
||||
async function columnType(pool, table, column) {
|
||||
const [rows] = await pool.query(
|
||||
`SELECT COLUMN_TYPE
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ? AND COLUMN_NAME = ?
|
||||
LIMIT 1`,
|
||||
[table, column],
|
||||
);
|
||||
return rows[0]?.COLUMN_TYPE ?? null;
|
||||
}
|
||||
|
||||
async function tableExists(pool, table) {
|
||||
const [rows] = await pool.query(
|
||||
`SELECT 1 FROM information_schema.TABLES
|
||||
@@ -285,7 +296,7 @@ export async function migrateSchema(pool) {
|
||||
await pool.query(`
|
||||
CREATE TABLE IF NOT EXISTS h5_llm_executor_bindings (
|
||||
id CHAR(36) PRIMARY KEY,
|
||||
executor ENUM('goose', 'aider', 'openhands') NOT NULL,
|
||||
executor ENUM('goose', 'aider', 'openhands', 'cursor') NOT NULL,
|
||||
purpose VARCHAR(32) NOT NULL DEFAULT 'default',
|
||||
provider_key_id CHAR(36) NULL,
|
||||
model VARCHAR(128) NOT NULL,
|
||||
@@ -297,6 +308,13 @@ export async function migrateSchema(pool) {
|
||||
CONSTRAINT fk_h5_llm_executor_provider FOREIGN KEY (provider_key_id) REFERENCES h5_llm_provider_keys(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
`);
|
||||
const executorColumnType = await columnType(pool, 'h5_llm_executor_bindings', 'executor');
|
||||
if (executorColumnType && !String(executorColumnType).includes("'cursor'")) {
|
||||
await pool.query(
|
||||
`ALTER TABLE h5_llm_executor_bindings
|
||||
MODIFY COLUMN executor ENUM('goose', 'aider', 'openhands', 'cursor') NOT NULL`,
|
||||
);
|
||||
}
|
||||
|
||||
// Optional asset capability control plane. These rows configure no runtime
|
||||
// worker by themselves; the existing chat/page path remains independent.
|
||||
@@ -441,6 +459,30 @@ export async function migrateSchema(pool) {
|
||||
);
|
||||
}
|
||||
|
||||
await pool.query(`
|
||||
CREATE TABLE IF NOT EXISTS h5_help_escalations (
|
||||
id CHAR(36) PRIMARY KEY,
|
||||
user_id CHAR(36) NOT NULL,
|
||||
channel VARCHAR(32) NOT NULL DEFAULT 'h5',
|
||||
status ENUM('queued', 'running', 'succeeded', 'failed') NOT NULL DEFAULT 'queued',
|
||||
user_text MEDIUMTEXT NOT NULL,
|
||||
context_json JSON NULL,
|
||||
agent_session_id VARCHAR(128) NULL,
|
||||
result_text MEDIUMTEXT NULL,
|
||||
agent_output MEDIUMTEXT NULL,
|
||||
error_message TEXT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
updated_at BIGINT NOT NULL,
|
||||
started_at BIGINT NULL,
|
||||
completed_at BIGINT NULL,
|
||||
KEY idx_h5_help_escalation_status_created (status, created_at),
|
||||
KEY idx_h5_help_escalation_user_created (user_id, created_at),
|
||||
KEY idx_h5_help_escalation_session (agent_session_id, updated_at),
|
||||
CONSTRAINT fk_h5_help_escalation_user FOREIGN KEY (user_id) REFERENCES h5_users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_h5_help_escalation_session FOREIGN KEY (agent_session_id) REFERENCES h5_user_sessions(agent_session_id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
`);
|
||||
|
||||
await ensureGoalRunSchema(pool, {
|
||||
columnExists: (table, column) => columnExists(pool, table, column),
|
||||
indexExists: (table, index) => indexExists(pool, table, index),
|
||||
|
||||
Reference in New Issue
Block a user