opencode-supertask 0.1.39 → 0.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -1
- package/LICENSE +21 -0
- package/README.md +159 -352
- package/README.zh-CN.md +250 -0
- package/dist/cli/index.js +580 -171
- package/dist/cli/index.js.map +1 -1
- package/dist/daemon/gateway-diagnostic-runner.d.ts +2 -0
- package/dist/daemon/gateway-diagnostic-runner.js +461 -0
- package/dist/daemon/gateway-diagnostic-runner.js.map +1 -0
- package/dist/gateway/index.js +543 -615
- package/dist/gateway/index.js.map +1 -1
- package/dist/plugin/supertask.js +90 -28
- package/dist/plugin/supertask.js.map +1 -1
- package/dist/web/index.js +410 -528
- package/dist/web/index.js.map +1 -1
- package/dist/worker/index.d.ts +9 -0
- package/dist/worker/index.js +225 -69
- package/dist/worker/index.js.map +1 -1
- package/dist/worker/launcher.js.map +1 -1
- package/drizzle/0008_good_smasher.sql +3 -0
- package/drizzle/meta/0008_snapshot.json +606 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +12 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/worker/launcher.ts","../../src/core/launch-protocol.ts"],"sourcesContent":["import { spawn } from 'child_process';\nimport {\n drainProofForIdentity,\n isLaunchIdentity,\n isMatchingDrainProofAck,\n LAUNCH_IDENTITY_ARGUMENT,\n} from '@core/launch-protocol';\n\nconst RELEASE_MESSAGE = 'START';\nconst INITIAL_GROUP_PROBE_DELAY_MS = 1_000;\nconst MAX_GROUP_PROBE_DELAY_MS = 5_000;\nconst GROUP_PROBE_TIMEOUT_MS = 2_000;\nconst MAX_PS_OUTPUT_CHARS = 4 * 1024 * 1024;\nconst DRAIN_PROOF_ACK_TIMEOUT_MS = 10_000;\n\nfunction waitForRelease(): Promise<boolean> {\n return new Promise((resolve) => {\n let settled = false;\n let input = '';\n const finish = (released: boolean) => {\n if (settled) return;\n settled = true;\n process.stdin.removeAllListeners();\n resolve(released);\n };\n\n process.stdin.setEncoding('utf8');\n process.stdin.on('data', (chunk: string) => {\n input += chunk;\n const newline = input.indexOf('\\n');\n if (newline >= 0) finish(input.slice(0, newline).trim() === RELEASE_MESSAGE);\n });\n process.stdin.once('end', () => finish(false));\n process.stdin.once('error', () => finish(false));\n process.stdin.resume();\n });\n}\n\nasync function hasOtherProcessGroupMembers(): Promise<boolean | null> {\n return new Promise((resolve) => {\n const inspection = spawn('ps', ['-axo', 'pid=,pgid='], {\n stdio: ['ignore', 'pipe', 'ignore'],\n });\n let output = '';\n let settled = false;\n const finish = (result: boolean | null) => {\n if (settled) return;\n settled = true;\n clearTimeout(timeout);\n resolve(result);\n };\n const timeout = setTimeout(() => {\n inspection.kill('SIGKILL');\n finish(null);\n }, GROUP_PROBE_TIMEOUT_MS);\n\n inspection.stdout.setEncoding('utf8');\n inspection.stdout.on('data', (chunk: string) => {\n output += chunk;\n if (output.length <= MAX_PS_OUTPUT_CHARS) return;\n inspection.kill('SIGKILL');\n finish(null);\n });\n inspection.once('error', () => finish(null));\n inspection.once('close', (code) => {\n if (code !== 0) {\n finish(null);\n return;\n }\n const hasMembers = output.split('\\n').some((line) => {\n const match = line.trim().match(/^(\\d+)\\s+(\\d+)$/);\n if (!match) return false;\n const pid = Number(match[1]);\n const processGroupId = Number(match[2]);\n return pid !== process.pid\n && pid !== inspection.pid\n && processGroupId === process.pid;\n });\n finish(hasMembers);\n });\n });\n}\n\nexport interface ProcessGroupDrainOptions {\n probe?: () => Promise<boolean | null>;\n delay?: (milliseconds: number) => Promise<void>;\n initialDelayMs?: number;\n maxDelayMs?: number;\n}\n\nexport async function waitForProcessGroupDrain(\n options: ProcessGroupDrainOptions = {},\n): Promise<void> {\n if (process.platform === 'win32') return;\n\n const probe = options.probe ?? hasOtherProcessGroupMembers;\n const delay = options.delay ?? Bun.sleep;\n const maxDelayMs = options.maxDelayMs ?? MAX_GROUP_PROBE_DELAY_MS;\n let probeDelayMs = options.initialDelayMs ?? INITIAL_GROUP_PROBE_DELAY_MS;\n while (true) {\n const hasMembers = await probe();\n if (hasMembers === false) return;\n await delay(probeDelayMs);\n probeDelayMs = Math.min(maxDelayMs, probeDelayMs * 2);\n }\n}\n\nasync function sendDrainProof(launchIdentity: string): Promise<void> {\n if (!process.send) throw new Error('supertask launcher: drain proof IPC unavailable');\n\n await new Promise<void>((resolve, reject) => {\n let settled = false;\n const finish = (error?: Error) => {\n if (settled) return;\n settled = true;\n clearTimeout(timeout);\n process.off('message', onMessage);\n process.off('disconnect', onDisconnect);\n if (error) reject(error);\n else resolve();\n };\n const onMessage = (message: unknown) => {\n if (isMatchingDrainProofAck(message, launchIdentity)) finish();\n };\n const onDisconnect = () => finish(\n new Error('supertask launcher: drain proof IPC disconnected before acknowledgment'),\n );\n const timeout = setTimeout(() => finish(\n new Error('supertask launcher: drain proof acknowledgment timed out'),\n ), DRAIN_PROOF_ACK_TIMEOUT_MS);\n\n process.on('message', onMessage);\n process.once('disconnect', onDisconnect);\n try {\n // Bun 1.1 can deliver IPC messages but does not reliably invoke\n // the Node-compatible process.send callback. A bound acknowledgment\n // proves delivery without depending on that callback.\n process.send!(drainProofForIdentity(launchIdentity));\n } catch (error) {\n finish(error instanceof Error ? error : new Error(String(error)));\n }\n });\n}\n\nasync function main(): Promise<void> {\n const launcherArgs = Bun.argv.slice(2);\n let launchIdentity: string | null = null;\n if (launcherArgs[0] === LAUNCH_IDENTITY_ARGUMENT) {\n if (!isLaunchIdentity(launcherArgs[1])) {\n console.error('supertask launcher: missing launch identity');\n process.exitCode = 127;\n return;\n }\n launchIdentity = launcherArgs[1];\n launcherArgs.splice(0, 2);\n }\n const [executable, ...args] = launcherArgs;\n if (!executable) {\n console.error('supertask launcher: missing OpenCode executable');\n process.exitCode = 127;\n return;\n }\n\n if (!await waitForRelease()) {\n process.exitCode = 125;\n return;\n }\n\n const preserveGroupLeader = () => {};\n process.on('SIGTERM', preserveGroupLeader);\n process.on('SIGINT', preserveGroupLeader);\n let result: { code: number | null; signal: NodeJS.Signals | null };\n try {\n const child = spawn(executable, args, {\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n child.stdout?.pipe(process.stdout, { end: false });\n child.stderr?.pipe(process.stderr, { end: false });\n result = await new Promise((resolve) => {\n child.once('error', (error) => {\n console.error(`supertask launcher: ${error.message}`);\n resolve({ code: 127, signal: null });\n });\n // 使用独立 pipe 转发输出;exit 只等 OpenCode 主进程结束,\n // 后续的进程组排空才是 guardian 退出的最终条件。\n child.once('exit', (code, signal) => resolve({ code, signal }));\n });\n\n // 保持进程组长存活,直到 OpenCode 派生的整棵进程树都退出。\n // Watchdog 因而始终可以通过 launcher 命令验证进程组归属,避免 PID/PGID 复用误杀。\n await waitForProcessGroupDrain();\n if (launchIdentity) {\n // IPC 不传递给 OpenCode;只有持有该次随机身份的 guardian\n // 可在整个进程组排空后向 Worker 发出绑定证明。\n await sendDrainProof(launchIdentity);\n }\n } finally {\n process.off('SIGTERM', preserveGroupLeader);\n process.off('SIGINT', preserveGroupLeader);\n }\n\n if (result.signal) {\n try {\n process.kill(process.pid, result.signal);\n return;\n } catch {\n process.exitCode = 128;\n return;\n }\n }\n process.exitCode = result.code ?? 1;\n}\n\nif (import.meta.main) await main();\n","export const LEGACY_GUARDIAN_LAUNCH_PROTOCOL = 'gated-v2-guardian';\nexport const TOKEN_GUARDIAN_LAUNCH_PROTOCOL = 'gated-v3-token-guardian';\nexport const LAUNCH_IDENTITY_ARGUMENT = '--supertask-launch-identity';\nexport const DRAIN_PROOF_MESSAGE_TYPE = 'supertask-drained';\nexport const DRAIN_PROOF_ACK_MESSAGE_TYPE = 'supertask-drained-ack';\nexport const MANAGED_RUN_ENV = 'SUPERTASK_MANAGED_RUN';\nexport const MANAGED_RUN_ENV_VALUE = '1';\n\nexport function isLaunchIdentity(value: string | null | undefined): value is string {\n return value != null\n && /^gateway-[1-9]\\d*:launch:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);\n}\n\nexport function drainProofForIdentity(launchIdentity: string) {\n return { type: DRAIN_PROOF_MESSAGE_TYPE, identity: launchIdentity } as const;\n}\n\nexport function drainProofAckForIdentity(launchIdentity: string) {\n return { type: DRAIN_PROOF_ACK_MESSAGE_TYPE, identity: launchIdentity } as const;\n}\n\nexport function isMatchingDrainProof(message: unknown, launchIdentity: string): boolean {\n if (typeof message !== 'object' || message == null) return false;\n const candidate = message as Record<string, unknown>;\n return candidate.type === DRAIN_PROOF_MESSAGE_TYPE\n && candidate.identity === launchIdentity;\n}\n\nexport function isMatchingDrainProofAck(message: unknown, launchIdentity: string): boolean {\n if (typeof message !== 'object' || message == null) return false;\n const candidate = message as Record<string, unknown>;\n return candidate.type === DRAIN_PROOF_ACK_MESSAGE_TYPE\n && candidate.identity === launchIdentity;\n}\n"],"mappings":";AAAA,SAAS,aAAa;;;ACEf,IAAM,2BAA2B;AACjC,IAAM,2BAA2B;AACjC,IAAM,+BAA+B;AAIrC,SAAS,iBAAiB,OAAmD;AAChF,SAAO,SAAS,QACT,iGAAiG,KAAK,KAAK;AACtH;AAEO,SAAS,sBAAsB,gBAAwB;AAC1D,SAAO,EAAE,MAAM,0BAA0B,UAAU,eAAe;AACtE;AAaO,SAAS,wBAAwB,SAAkB,gBAAiC;AACvF,MAAI,OAAO,YAAY,YAAY,WAAW,KAAM,QAAO;AAC3D,QAAM,YAAY;AAClB,SAAO,UAAU,SAAS,gCACnB,UAAU,aAAa;AAClC;;;ADzBA,IAAM,kBAAkB;AACxB,IAAM,+BAA+B;AACrC,IAAM,2BAA2B;AACjC,IAAM,yBAAyB;AAC/B,IAAM,sBAAsB,IAAI,OAAO;AACvC,IAAM,6BAA6B;AAEnC,SAAS,iBAAmC;AACxC,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC5B,QAAI,UAAU;AACd,QAAI,QAAQ;AACZ,UAAM,SAAS,CAAC,aAAsB;AAClC,UAAI,QAAS;AACb,gB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SAAS,CAAC,UAAU;AAC3B,gBAAQ,MAAM,uBAAuB,MAAM,OAAO,EAAE;AACpD,gBAAQ,EAAE,MAAM,KAAK,QAAQ,KAAK,CAAC;AAAA,MACvC,CAAC;AAGD,YAAM,KAAK,QAAQ,CAAC,MAAM,WAAW,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC;AAAA,IAClE,CAAC;AAID,UAAM,yBAAyB;AAC/B,QAAI,gBAAgB;AAGhB,YAAM,eAAe,cAAc;AAAA,IACvC;AAAA,EACJ,UAAE;AACE,YAAQ,IAAI,WAAW,mBAAmB;AAC1C,YAAQ,IAAI,UAAU,mBAAmB;AAAA,EAC7C;AAEA,MAAI,OAAO,QAAQ;AACf,QAAI;AACA,cAAQ,KAAK,QAAQ,KAAK,OAAO,MAAM;AACvC;AAAA,IACJ,QAAQ;AACJ,cAAQ,WAAW;AACnB;AAAA,IACJ;AAAA,EACJ;AACA,UAAQ,WAAW,OAAO,QAAQ;AACtC;AAEA,IAAI,YAAY,KAAM,OAAM,KAAK;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/worker/launcher.ts","../../src/core/launch-protocol.ts"],"sourcesContent":["import { spawn } from 'child_process';\nimport {\n drainProofForIdentity,\n isLaunchIdentity,\n isMatchingDrainProofAck,\n LAUNCH_IDENTITY_ARGUMENT,\n} from '@core/launch-protocol';\n\nconst RELEASE_MESSAGE = 'START';\nconst INITIAL_GROUP_PROBE_DELAY_MS = 1_000;\nconst MAX_GROUP_PROBE_DELAY_MS = 5_000;\nconst GROUP_PROBE_TIMEOUT_MS = 2_000;\nconst MAX_PS_OUTPUT_CHARS = 4 * 1024 * 1024;\nconst DRAIN_PROOF_ACK_TIMEOUT_MS = 10_000;\n\nfunction waitForRelease(): Promise<boolean> {\n return new Promise((resolve) => {\n let settled = false;\n let input = '';\n const finish = (released: boolean) => {\n if (settled) return;\n settled = true;\n process.stdin.removeAllListeners();\n resolve(released);\n };\n\n process.stdin.setEncoding('utf8');\n process.stdin.on('data', (chunk: string) => {\n input += chunk;\n const newline = input.indexOf('\\n');\n if (newline >= 0) finish(input.slice(0, newline).trim() === RELEASE_MESSAGE);\n });\n process.stdin.once('end', () => finish(false));\n process.stdin.once('error', () => finish(false));\n process.stdin.resume();\n });\n}\n\nasync function hasOtherProcessGroupMembers(): Promise<boolean | null> {\n return new Promise((resolve) => {\n const inspection = spawn('ps', ['-axo', 'pid=,pgid='], {\n stdio: ['ignore', 'pipe', 'ignore'],\n });\n let output = '';\n let settled = false;\n const finish = (result: boolean | null) => {\n if (settled) return;\n settled = true;\n clearTimeout(timeout);\n resolve(result);\n };\n const timeout = setTimeout(() => {\n inspection.kill('SIGKILL');\n finish(null);\n }, GROUP_PROBE_TIMEOUT_MS);\n\n inspection.stdout.setEncoding('utf8');\n inspection.stdout.on('data', (chunk: string) => {\n output += chunk;\n if (output.length <= MAX_PS_OUTPUT_CHARS) return;\n inspection.kill('SIGKILL');\n finish(null);\n });\n inspection.once('error', () => finish(null));\n inspection.once('close', (code) => {\n if (code !== 0) {\n finish(null);\n return;\n }\n const hasMembers = output.split('\\n').some((line) => {\n const match = line.trim().match(/^(\\d+)\\s+(\\d+)$/);\n if (!match) return false;\n const pid = Number(match[1]);\n const processGroupId = Number(match[2]);\n return pid !== process.pid\n && pid !== inspection.pid\n && processGroupId === process.pid;\n });\n finish(hasMembers);\n });\n });\n}\n\nexport interface ProcessGroupDrainOptions {\n probe?: () => Promise<boolean | null>;\n delay?: (milliseconds: number) => Promise<void>;\n initialDelayMs?: number;\n maxDelayMs?: number;\n}\n\nexport async function waitForProcessGroupDrain(\n options: ProcessGroupDrainOptions = {},\n): Promise<void> {\n if (process.platform === 'win32') return;\n\n const probe = options.probe ?? hasOtherProcessGroupMembers;\n const delay = options.delay ?? Bun.sleep;\n const maxDelayMs = options.maxDelayMs ?? MAX_GROUP_PROBE_DELAY_MS;\n let probeDelayMs = options.initialDelayMs ?? INITIAL_GROUP_PROBE_DELAY_MS;\n while (true) {\n const hasMembers = await probe();\n if (hasMembers === false) return;\n await delay(probeDelayMs);\n probeDelayMs = Math.min(maxDelayMs, probeDelayMs * 2);\n }\n}\n\nasync function sendDrainProof(launchIdentity: string): Promise<void> {\n if (!process.send) throw new Error('supertask launcher: drain proof IPC unavailable');\n\n await new Promise<void>((resolve, reject) => {\n let settled = false;\n const finish = (error?: Error) => {\n if (settled) return;\n settled = true;\n clearTimeout(timeout);\n process.off('message', onMessage);\n process.off('disconnect', onDisconnect);\n if (error) reject(error);\n else resolve();\n };\n const onMessage = (message: unknown) => {\n if (isMatchingDrainProofAck(message, launchIdentity)) finish();\n };\n const onDisconnect = () => finish(\n new Error('supertask launcher: drain proof IPC disconnected before acknowledgment'),\n );\n const timeout = setTimeout(() => finish(\n new Error('supertask launcher: drain proof acknowledgment timed out'),\n ), DRAIN_PROOF_ACK_TIMEOUT_MS);\n\n process.on('message', onMessage);\n process.once('disconnect', onDisconnect);\n try {\n // Bun 1.1 can deliver IPC messages but does not reliably invoke\n // the Node-compatible process.send callback. A bound acknowledgment\n // proves delivery without depending on that callback.\n process.send!(drainProofForIdentity(launchIdentity));\n } catch (error) {\n finish(error instanceof Error ? error : new Error(String(error)));\n }\n });\n}\n\nasync function main(): Promise<void> {\n const launcherArgs = Bun.argv.slice(2);\n let launchIdentity: string | null = null;\n if (launcherArgs[0] === LAUNCH_IDENTITY_ARGUMENT) {\n if (!isLaunchIdentity(launcherArgs[1])) {\n console.error('supertask launcher: missing launch identity');\n process.exitCode = 127;\n return;\n }\n launchIdentity = launcherArgs[1];\n launcherArgs.splice(0, 2);\n }\n const [executable, ...args] = launcherArgs;\n if (!executable) {\n console.error('supertask launcher: missing OpenCode executable');\n process.exitCode = 127;\n return;\n }\n\n if (!await waitForRelease()) {\n process.exitCode = 125;\n return;\n }\n\n const preserveGroupLeader = () => {};\n process.on('SIGTERM', preserveGroupLeader);\n process.on('SIGINT', preserveGroupLeader);\n let result: { code: number | null; signal: NodeJS.Signals | null };\n try {\n const child = spawn(executable, args, {\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n child.stdout?.pipe(process.stdout, { end: false });\n child.stderr?.pipe(process.stderr, { end: false });\n result = await new Promise((resolve) => {\n child.once('error', (error) => {\n console.error(`supertask launcher: ${error.message}`);\n resolve({ code: 127, signal: null });\n });\n // 使用独立 pipe 转发输出;exit 只等 OpenCode 主进程结束,\n // 后续的进程组排空才是 guardian 退出的最终条件。\n child.once('exit', (code, signal) => resolve({ code, signal }));\n });\n\n // 保持进程组长存活,直到仍属于该受管进程组的进程全部退出。\n // Watchdog 因而始终可以通过 launcher 命令验证进程组归属,避免 PID/PGID 复用误杀。\n await waitForProcessGroupDrain();\n if (launchIdentity) {\n // IPC 不传递给 OpenCode;只有持有该次随机身份的 guardian\n // 可在整个进程组排空后向 Worker 发出绑定证明。\n await sendDrainProof(launchIdentity);\n }\n } finally {\n process.off('SIGTERM', preserveGroupLeader);\n process.off('SIGINT', preserveGroupLeader);\n }\n\n if (result.signal) {\n try {\n process.kill(process.pid, result.signal);\n return;\n } catch {\n process.exitCode = 128;\n return;\n }\n }\n process.exitCode = result.code ?? 1;\n}\n\nif (import.meta.main) await main();\n","export const LEGACY_GUARDIAN_LAUNCH_PROTOCOL = 'gated-v2-guardian';\nexport const TOKEN_GUARDIAN_LAUNCH_PROTOCOL = 'gated-v3-token-guardian';\nexport const LAUNCH_IDENTITY_ARGUMENT = '--supertask-launch-identity';\nexport const DRAIN_PROOF_MESSAGE_TYPE = 'supertask-drained';\nexport const DRAIN_PROOF_ACK_MESSAGE_TYPE = 'supertask-drained-ack';\nexport const MANAGED_RUN_ENV = 'SUPERTASK_MANAGED_RUN';\nexport const MANAGED_RUN_ENV_VALUE = '1';\n\nexport function isLaunchIdentity(value: string | null | undefined): value is string {\n return value != null\n && /^gateway-[1-9]\\d*:launch:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);\n}\n\nexport function drainProofForIdentity(launchIdentity: string) {\n return { type: DRAIN_PROOF_MESSAGE_TYPE, identity: launchIdentity } as const;\n}\n\nexport function drainProofAckForIdentity(launchIdentity: string) {\n return { type: DRAIN_PROOF_ACK_MESSAGE_TYPE, identity: launchIdentity } as const;\n}\n\nexport function isMatchingDrainProof(message: unknown, launchIdentity: string): boolean {\n if (typeof message !== 'object' || message == null) return false;\n const candidate = message as Record<string, unknown>;\n return candidate.type === DRAIN_PROOF_MESSAGE_TYPE\n && candidate.identity === launchIdentity;\n}\n\nexport function isMatchingDrainProofAck(message: unknown, launchIdentity: string): boolean {\n if (typeof message !== 'object' || message == null) return false;\n const candidate = message as Record<string, unknown>;\n return candidate.type === DRAIN_PROOF_ACK_MESSAGE_TYPE\n && candidate.identity === launchIdentity;\n}\n"],"mappings":";AAAA,SAAS,aAAa;;;ACEf,IAAM,2BAA2B;AACjC,IAAM,2BAA2B;AACjC,IAAM,+BAA+B;AAIrC,SAAS,iBAAiB,OAAmD;AAChF,SAAO,SAAS,QACT,iGAAiG,KAAK,KAAK;AACtH;AAEO,SAAS,sBAAsB,gBAAwB;AAC1D,SAAO,EAAE,MAAM,0BAA0B,UAAU,eAAe;AACtE;AAaO,SAAS,wBAAwB,SAAkB,gBAAiC;AACvF,MAAI,OAAO,YAAY,YAAY,WAAW,KAAM,QAAO;AAC3D,QAAM,YAAY;AAClB,SAAO,UAAU,SAAS,gCACnB,UAAU,aAAa;AAClC;;;ADzBA,IAAM,kBAAkB;AACxB,IAAM,+BAA+B;AACrC,IAAM,2BAA2B;AACjC,IAAM,yBAAyB;AAC/B,IAAM,sBAAsB,IAAI,OAAO;AACvC,IAAM,6BAA6B;AAEnC,SAAS,iBAAmC;AACxC,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC5B,QAAI,UAAU;AACd,QAAI,QAAQ;AACZ,UAAM,SAAS,CAAC,aAAsB;AAClC,UAAI,QAAS;AACb,gBAAU;AACV,cAAQ,MAAM,mBAAmB;AACjC,cAAQ,QAAQ;AAAA,IACpB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AE;AACpD,gBAAQ,EAAE,MAAM,KAAK,QAAQ,KAAK,CAAC;AAAA,MACvC,CAAC;AAGD,YAAM,KAAK,QAAQ,CAAC,MAAM,WAAW,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC;AAAA,IAClE,CAAC;AAID,UAAM,yBAAyB;AAC/B,QAAI,gBAAgB;AAGhB,YAAM,eAAe,cAAc;AAAA,IACvC;AAAA,EACJ,UAAE;AACE,YAAQ,IAAI,WAAW,mBAAmB;AAC1C,YAAQ,IAAI,UAAU,mBAAmB;AAAA,EAC7C;AAEA,MAAI,OAAO,QAAQ;AACf,QAAI;AACA,cAAQ,KAAK,QAAQ,KAAK,OAAO,MAAM;AACvC;AAAA,IACJ,QAAQ;AACJ,cAAQ,WAAW;AACnB;AAAA,IACJ;AAAA,EACJ;AACA,UAAQ,WAAW,OAAO,QAAQ;AACtC;AAEA,IAAI,YAAY,KAAM,OAAM,KAAK;","names":[]}
|
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "6",
|
|
3
|
+
"dialect": "sqlite",
|
|
4
|
+
"id": "45888528-ef6d-47d9-a319-c653461f5407",
|
|
5
|
+
"prevId": "47ce89a9-1834-4e73-acbd-1109d32ec358",
|
|
6
|
+
"tables": {
|
|
7
|
+
"task_runs": {
|
|
8
|
+
"name": "task_runs",
|
|
9
|
+
"columns": {
|
|
10
|
+
"id": {
|
|
11
|
+
"name": "id",
|
|
12
|
+
"type": "integer",
|
|
13
|
+
"primaryKey": true,
|
|
14
|
+
"notNull": true,
|
|
15
|
+
"autoincrement": true
|
|
16
|
+
},
|
|
17
|
+
"task_id": {
|
|
18
|
+
"name": "task_id",
|
|
19
|
+
"type": "integer",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": true,
|
|
22
|
+
"autoincrement": false
|
|
23
|
+
},
|
|
24
|
+
"session_id": {
|
|
25
|
+
"name": "session_id",
|
|
26
|
+
"type": "text",
|
|
27
|
+
"primaryKey": false,
|
|
28
|
+
"notNull": false,
|
|
29
|
+
"autoincrement": false
|
|
30
|
+
},
|
|
31
|
+
"model": {
|
|
32
|
+
"name": "model",
|
|
33
|
+
"type": "text",
|
|
34
|
+
"primaryKey": false,
|
|
35
|
+
"notNull": false,
|
|
36
|
+
"autoincrement": false
|
|
37
|
+
},
|
|
38
|
+
"variant": {
|
|
39
|
+
"name": "variant",
|
|
40
|
+
"type": "text",
|
|
41
|
+
"primaryKey": false,
|
|
42
|
+
"notNull": false,
|
|
43
|
+
"autoincrement": false
|
|
44
|
+
},
|
|
45
|
+
"status": {
|
|
46
|
+
"name": "status",
|
|
47
|
+
"type": "text",
|
|
48
|
+
"primaryKey": false,
|
|
49
|
+
"notNull": false,
|
|
50
|
+
"autoincrement": false,
|
|
51
|
+
"default": "'running'"
|
|
52
|
+
},
|
|
53
|
+
"started_at": {
|
|
54
|
+
"name": "started_at",
|
|
55
|
+
"type": "integer",
|
|
56
|
+
"primaryKey": false,
|
|
57
|
+
"notNull": false,
|
|
58
|
+
"autoincrement": false
|
|
59
|
+
},
|
|
60
|
+
"finished_at": {
|
|
61
|
+
"name": "finished_at",
|
|
62
|
+
"type": "integer",
|
|
63
|
+
"primaryKey": false,
|
|
64
|
+
"notNull": false,
|
|
65
|
+
"autoincrement": false
|
|
66
|
+
},
|
|
67
|
+
"log": {
|
|
68
|
+
"name": "log",
|
|
69
|
+
"type": "text",
|
|
70
|
+
"primaryKey": false,
|
|
71
|
+
"notNull": false,
|
|
72
|
+
"autoincrement": false
|
|
73
|
+
},
|
|
74
|
+
"locked_at": {
|
|
75
|
+
"name": "locked_at",
|
|
76
|
+
"type": "integer",
|
|
77
|
+
"primaryKey": false,
|
|
78
|
+
"notNull": false,
|
|
79
|
+
"autoincrement": false
|
|
80
|
+
},
|
|
81
|
+
"locked_by": {
|
|
82
|
+
"name": "locked_by",
|
|
83
|
+
"type": "text",
|
|
84
|
+
"primaryKey": false,
|
|
85
|
+
"notNull": false,
|
|
86
|
+
"autoincrement": false
|
|
87
|
+
},
|
|
88
|
+
"heartbeat_at": {
|
|
89
|
+
"name": "heartbeat_at",
|
|
90
|
+
"type": "integer",
|
|
91
|
+
"primaryKey": false,
|
|
92
|
+
"notNull": false,
|
|
93
|
+
"autoincrement": false
|
|
94
|
+
},
|
|
95
|
+
"worker_pid": {
|
|
96
|
+
"name": "worker_pid",
|
|
97
|
+
"type": "integer",
|
|
98
|
+
"primaryKey": false,
|
|
99
|
+
"notNull": false,
|
|
100
|
+
"autoincrement": false
|
|
101
|
+
},
|
|
102
|
+
"child_pid": {
|
|
103
|
+
"name": "child_pid",
|
|
104
|
+
"type": "integer",
|
|
105
|
+
"primaryKey": false,
|
|
106
|
+
"notNull": false,
|
|
107
|
+
"autoincrement": false
|
|
108
|
+
},
|
|
109
|
+
"launch_protocol": {
|
|
110
|
+
"name": "launch_protocol",
|
|
111
|
+
"type": "text",
|
|
112
|
+
"primaryKey": false,
|
|
113
|
+
"notNull": false,
|
|
114
|
+
"autoincrement": false
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"indexes": {
|
|
118
|
+
"task_runs_task_started_idx": {
|
|
119
|
+
"name": "task_runs_task_started_idx",
|
|
120
|
+
"columns": [
|
|
121
|
+
"task_id",
|
|
122
|
+
"started_at",
|
|
123
|
+
"id"
|
|
124
|
+
],
|
|
125
|
+
"isUnique": false
|
|
126
|
+
},
|
|
127
|
+
"task_runs_status_heartbeat_idx": {
|
|
128
|
+
"name": "task_runs_status_heartbeat_idx",
|
|
129
|
+
"columns": [
|
|
130
|
+
"status",
|
|
131
|
+
"heartbeat_at"
|
|
132
|
+
],
|
|
133
|
+
"isUnique": false
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"foreignKeys": {
|
|
137
|
+
"task_runs_task_id_tasks_id_fk": {
|
|
138
|
+
"name": "task_runs_task_id_tasks_id_fk",
|
|
139
|
+
"tableFrom": "task_runs",
|
|
140
|
+
"tableTo": "tasks",
|
|
141
|
+
"columnsFrom": [
|
|
142
|
+
"task_id"
|
|
143
|
+
],
|
|
144
|
+
"columnsTo": [
|
|
145
|
+
"id"
|
|
146
|
+
],
|
|
147
|
+
"onDelete": "cascade",
|
|
148
|
+
"onUpdate": "no action"
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"compositePrimaryKeys": {},
|
|
152
|
+
"uniqueConstraints": {},
|
|
153
|
+
"checkConstraints": {}
|
|
154
|
+
},
|
|
155
|
+
"task_templates": {
|
|
156
|
+
"name": "task_templates",
|
|
157
|
+
"columns": {
|
|
158
|
+
"id": {
|
|
159
|
+
"name": "id",
|
|
160
|
+
"type": "integer",
|
|
161
|
+
"primaryKey": true,
|
|
162
|
+
"notNull": true,
|
|
163
|
+
"autoincrement": true
|
|
164
|
+
},
|
|
165
|
+
"name": {
|
|
166
|
+
"name": "name",
|
|
167
|
+
"type": "text",
|
|
168
|
+
"primaryKey": false,
|
|
169
|
+
"notNull": true,
|
|
170
|
+
"autoincrement": false
|
|
171
|
+
},
|
|
172
|
+
"agent": {
|
|
173
|
+
"name": "agent",
|
|
174
|
+
"type": "text",
|
|
175
|
+
"primaryKey": false,
|
|
176
|
+
"notNull": true,
|
|
177
|
+
"autoincrement": false
|
|
178
|
+
},
|
|
179
|
+
"model": {
|
|
180
|
+
"name": "model",
|
|
181
|
+
"type": "text",
|
|
182
|
+
"primaryKey": false,
|
|
183
|
+
"notNull": false,
|
|
184
|
+
"autoincrement": false,
|
|
185
|
+
"default": "'default'"
|
|
186
|
+
},
|
|
187
|
+
"variant": {
|
|
188
|
+
"name": "variant",
|
|
189
|
+
"type": "text",
|
|
190
|
+
"primaryKey": false,
|
|
191
|
+
"notNull": false,
|
|
192
|
+
"autoincrement": false
|
|
193
|
+
},
|
|
194
|
+
"prompt": {
|
|
195
|
+
"name": "prompt",
|
|
196
|
+
"type": "text",
|
|
197
|
+
"primaryKey": false,
|
|
198
|
+
"notNull": true,
|
|
199
|
+
"autoincrement": false
|
|
200
|
+
},
|
|
201
|
+
"cwd": {
|
|
202
|
+
"name": "cwd",
|
|
203
|
+
"type": "text",
|
|
204
|
+
"primaryKey": false,
|
|
205
|
+
"notNull": false,
|
|
206
|
+
"autoincrement": false
|
|
207
|
+
},
|
|
208
|
+
"category": {
|
|
209
|
+
"name": "category",
|
|
210
|
+
"type": "text",
|
|
211
|
+
"primaryKey": false,
|
|
212
|
+
"notNull": false,
|
|
213
|
+
"autoincrement": false,
|
|
214
|
+
"default": "'general'"
|
|
215
|
+
},
|
|
216
|
+
"importance": {
|
|
217
|
+
"name": "importance",
|
|
218
|
+
"type": "integer",
|
|
219
|
+
"primaryKey": false,
|
|
220
|
+
"notNull": false,
|
|
221
|
+
"autoincrement": false,
|
|
222
|
+
"default": 3
|
|
223
|
+
},
|
|
224
|
+
"urgency": {
|
|
225
|
+
"name": "urgency",
|
|
226
|
+
"type": "integer",
|
|
227
|
+
"primaryKey": false,
|
|
228
|
+
"notNull": false,
|
|
229
|
+
"autoincrement": false,
|
|
230
|
+
"default": 3
|
|
231
|
+
},
|
|
232
|
+
"batch_id": {
|
|
233
|
+
"name": "batch_id",
|
|
234
|
+
"type": "text",
|
|
235
|
+
"primaryKey": false,
|
|
236
|
+
"notNull": false,
|
|
237
|
+
"autoincrement": false
|
|
238
|
+
},
|
|
239
|
+
"schedule_type": {
|
|
240
|
+
"name": "schedule_type",
|
|
241
|
+
"type": "text",
|
|
242
|
+
"primaryKey": false,
|
|
243
|
+
"notNull": true,
|
|
244
|
+
"autoincrement": false
|
|
245
|
+
},
|
|
246
|
+
"cron_expr": {
|
|
247
|
+
"name": "cron_expr",
|
|
248
|
+
"type": "text",
|
|
249
|
+
"primaryKey": false,
|
|
250
|
+
"notNull": false,
|
|
251
|
+
"autoincrement": false
|
|
252
|
+
},
|
|
253
|
+
"interval_ms": {
|
|
254
|
+
"name": "interval_ms",
|
|
255
|
+
"type": "integer",
|
|
256
|
+
"primaryKey": false,
|
|
257
|
+
"notNull": false,
|
|
258
|
+
"autoincrement": false
|
|
259
|
+
},
|
|
260
|
+
"run_at": {
|
|
261
|
+
"name": "run_at",
|
|
262
|
+
"type": "integer",
|
|
263
|
+
"primaryKey": false,
|
|
264
|
+
"notNull": false,
|
|
265
|
+
"autoincrement": false
|
|
266
|
+
},
|
|
267
|
+
"max_instances": {
|
|
268
|
+
"name": "max_instances",
|
|
269
|
+
"type": "integer",
|
|
270
|
+
"primaryKey": false,
|
|
271
|
+
"notNull": false,
|
|
272
|
+
"autoincrement": false,
|
|
273
|
+
"default": 1
|
|
274
|
+
},
|
|
275
|
+
"max_retries": {
|
|
276
|
+
"name": "max_retries",
|
|
277
|
+
"type": "integer",
|
|
278
|
+
"primaryKey": false,
|
|
279
|
+
"notNull": false,
|
|
280
|
+
"autoincrement": false,
|
|
281
|
+
"default": 3
|
|
282
|
+
},
|
|
283
|
+
"retry_backoff_ms": {
|
|
284
|
+
"name": "retry_backoff_ms",
|
|
285
|
+
"type": "integer",
|
|
286
|
+
"primaryKey": false,
|
|
287
|
+
"notNull": false,
|
|
288
|
+
"autoincrement": false,
|
|
289
|
+
"default": 30000
|
|
290
|
+
},
|
|
291
|
+
"timeout_ms": {
|
|
292
|
+
"name": "timeout_ms",
|
|
293
|
+
"type": "integer",
|
|
294
|
+
"primaryKey": false,
|
|
295
|
+
"notNull": false,
|
|
296
|
+
"autoincrement": false
|
|
297
|
+
},
|
|
298
|
+
"last_run_at": {
|
|
299
|
+
"name": "last_run_at",
|
|
300
|
+
"type": "integer",
|
|
301
|
+
"primaryKey": false,
|
|
302
|
+
"notNull": false,
|
|
303
|
+
"autoincrement": false
|
|
304
|
+
},
|
|
305
|
+
"next_run_at": {
|
|
306
|
+
"name": "next_run_at",
|
|
307
|
+
"type": "integer",
|
|
308
|
+
"primaryKey": false,
|
|
309
|
+
"notNull": false,
|
|
310
|
+
"autoincrement": false
|
|
311
|
+
},
|
|
312
|
+
"enabled": {
|
|
313
|
+
"name": "enabled",
|
|
314
|
+
"type": "integer",
|
|
315
|
+
"primaryKey": false,
|
|
316
|
+
"notNull": false,
|
|
317
|
+
"autoincrement": false,
|
|
318
|
+
"default": true
|
|
319
|
+
},
|
|
320
|
+
"created_at": {
|
|
321
|
+
"name": "created_at",
|
|
322
|
+
"type": "integer",
|
|
323
|
+
"primaryKey": false,
|
|
324
|
+
"notNull": false,
|
|
325
|
+
"autoincrement": false,
|
|
326
|
+
"default": 0
|
|
327
|
+
},
|
|
328
|
+
"updated_at": {
|
|
329
|
+
"name": "updated_at",
|
|
330
|
+
"type": "integer",
|
|
331
|
+
"primaryKey": false,
|
|
332
|
+
"notNull": false,
|
|
333
|
+
"autoincrement": false,
|
|
334
|
+
"default": 0
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
"indexes": {
|
|
338
|
+
"task_templates_due_idx": {
|
|
339
|
+
"name": "task_templates_due_idx",
|
|
340
|
+
"columns": [
|
|
341
|
+
"enabled",
|
|
342
|
+
"next_run_at",
|
|
343
|
+
"id"
|
|
344
|
+
],
|
|
345
|
+
"isUnique": false
|
|
346
|
+
},
|
|
347
|
+
"task_templates_retention_idx": {
|
|
348
|
+
"name": "task_templates_retention_idx",
|
|
349
|
+
"columns": [
|
|
350
|
+
"schedule_type",
|
|
351
|
+
"enabled",
|
|
352
|
+
"last_run_at",
|
|
353
|
+
"id"
|
|
354
|
+
],
|
|
355
|
+
"isUnique": false
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
"foreignKeys": {},
|
|
359
|
+
"compositePrimaryKeys": {},
|
|
360
|
+
"uniqueConstraints": {},
|
|
361
|
+
"checkConstraints": {}
|
|
362
|
+
},
|
|
363
|
+
"tasks": {
|
|
364
|
+
"name": "tasks",
|
|
365
|
+
"columns": {
|
|
366
|
+
"id": {
|
|
367
|
+
"name": "id",
|
|
368
|
+
"type": "integer",
|
|
369
|
+
"primaryKey": true,
|
|
370
|
+
"notNull": true,
|
|
371
|
+
"autoincrement": true
|
|
372
|
+
},
|
|
373
|
+
"name": {
|
|
374
|
+
"name": "name",
|
|
375
|
+
"type": "text",
|
|
376
|
+
"primaryKey": false,
|
|
377
|
+
"notNull": true,
|
|
378
|
+
"autoincrement": false
|
|
379
|
+
},
|
|
380
|
+
"agent": {
|
|
381
|
+
"name": "agent",
|
|
382
|
+
"type": "text",
|
|
383
|
+
"primaryKey": false,
|
|
384
|
+
"notNull": true,
|
|
385
|
+
"autoincrement": false
|
|
386
|
+
},
|
|
387
|
+
"model": {
|
|
388
|
+
"name": "model",
|
|
389
|
+
"type": "text",
|
|
390
|
+
"primaryKey": false,
|
|
391
|
+
"notNull": false,
|
|
392
|
+
"autoincrement": false,
|
|
393
|
+
"default": "'default'"
|
|
394
|
+
},
|
|
395
|
+
"variant": {
|
|
396
|
+
"name": "variant",
|
|
397
|
+
"type": "text",
|
|
398
|
+
"primaryKey": false,
|
|
399
|
+
"notNull": false,
|
|
400
|
+
"autoincrement": false
|
|
401
|
+
},
|
|
402
|
+
"prompt": {
|
|
403
|
+
"name": "prompt",
|
|
404
|
+
"type": "text",
|
|
405
|
+
"primaryKey": false,
|
|
406
|
+
"notNull": true,
|
|
407
|
+
"autoincrement": false
|
|
408
|
+
},
|
|
409
|
+
"cwd": {
|
|
410
|
+
"name": "cwd",
|
|
411
|
+
"type": "text",
|
|
412
|
+
"primaryKey": false,
|
|
413
|
+
"notNull": false,
|
|
414
|
+
"autoincrement": false
|
|
415
|
+
},
|
|
416
|
+
"category": {
|
|
417
|
+
"name": "category",
|
|
418
|
+
"type": "text",
|
|
419
|
+
"primaryKey": false,
|
|
420
|
+
"notNull": false,
|
|
421
|
+
"autoincrement": false,
|
|
422
|
+
"default": "'general'"
|
|
423
|
+
},
|
|
424
|
+
"importance": {
|
|
425
|
+
"name": "importance",
|
|
426
|
+
"type": "integer",
|
|
427
|
+
"primaryKey": false,
|
|
428
|
+
"notNull": false,
|
|
429
|
+
"autoincrement": false,
|
|
430
|
+
"default": 3
|
|
431
|
+
},
|
|
432
|
+
"urgency": {
|
|
433
|
+
"name": "urgency",
|
|
434
|
+
"type": "integer",
|
|
435
|
+
"primaryKey": false,
|
|
436
|
+
"notNull": false,
|
|
437
|
+
"autoincrement": false,
|
|
438
|
+
"default": 3
|
|
439
|
+
},
|
|
440
|
+
"batch_id": {
|
|
441
|
+
"name": "batch_id",
|
|
442
|
+
"type": "text",
|
|
443
|
+
"primaryKey": false,
|
|
444
|
+
"notNull": false,
|
|
445
|
+
"autoincrement": false
|
|
446
|
+
},
|
|
447
|
+
"depends_on": {
|
|
448
|
+
"name": "depends_on",
|
|
449
|
+
"type": "integer",
|
|
450
|
+
"primaryKey": false,
|
|
451
|
+
"notNull": false,
|
|
452
|
+
"autoincrement": false
|
|
453
|
+
},
|
|
454
|
+
"status": {
|
|
455
|
+
"name": "status",
|
|
456
|
+
"type": "text",
|
|
457
|
+
"primaryKey": false,
|
|
458
|
+
"notNull": false,
|
|
459
|
+
"autoincrement": false,
|
|
460
|
+
"default": "'pending'"
|
|
461
|
+
},
|
|
462
|
+
"created_at": {
|
|
463
|
+
"name": "created_at",
|
|
464
|
+
"type": "integer",
|
|
465
|
+
"primaryKey": false,
|
|
466
|
+
"notNull": false,
|
|
467
|
+
"autoincrement": false
|
|
468
|
+
},
|
|
469
|
+
"started_at": {
|
|
470
|
+
"name": "started_at",
|
|
471
|
+
"type": "integer",
|
|
472
|
+
"primaryKey": false,
|
|
473
|
+
"notNull": false,
|
|
474
|
+
"autoincrement": false
|
|
475
|
+
},
|
|
476
|
+
"finished_at": {
|
|
477
|
+
"name": "finished_at",
|
|
478
|
+
"type": "integer",
|
|
479
|
+
"primaryKey": false,
|
|
480
|
+
"notNull": false,
|
|
481
|
+
"autoincrement": false
|
|
482
|
+
},
|
|
483
|
+
"result_log": {
|
|
484
|
+
"name": "result_log",
|
|
485
|
+
"type": "text",
|
|
486
|
+
"primaryKey": false,
|
|
487
|
+
"notNull": false,
|
|
488
|
+
"autoincrement": false
|
|
489
|
+
},
|
|
490
|
+
"retry_count": {
|
|
491
|
+
"name": "retry_count",
|
|
492
|
+
"type": "integer",
|
|
493
|
+
"primaryKey": false,
|
|
494
|
+
"notNull": false,
|
|
495
|
+
"autoincrement": false,
|
|
496
|
+
"default": 0
|
|
497
|
+
},
|
|
498
|
+
"max_retries": {
|
|
499
|
+
"name": "max_retries",
|
|
500
|
+
"type": "integer",
|
|
501
|
+
"primaryKey": false,
|
|
502
|
+
"notNull": false,
|
|
503
|
+
"autoincrement": false,
|
|
504
|
+
"default": 3
|
|
505
|
+
},
|
|
506
|
+
"retry_backoff_ms": {
|
|
507
|
+
"name": "retry_backoff_ms",
|
|
508
|
+
"type": "integer",
|
|
509
|
+
"primaryKey": false,
|
|
510
|
+
"notNull": false,
|
|
511
|
+
"autoincrement": false,
|
|
512
|
+
"default": 30000
|
|
513
|
+
},
|
|
514
|
+
"retry_after": {
|
|
515
|
+
"name": "retry_after",
|
|
516
|
+
"type": "integer",
|
|
517
|
+
"primaryKey": false,
|
|
518
|
+
"notNull": false,
|
|
519
|
+
"autoincrement": false
|
|
520
|
+
},
|
|
521
|
+
"timeout_ms": {
|
|
522
|
+
"name": "timeout_ms",
|
|
523
|
+
"type": "integer",
|
|
524
|
+
"primaryKey": false,
|
|
525
|
+
"notNull": false,
|
|
526
|
+
"autoincrement": false
|
|
527
|
+
},
|
|
528
|
+
"template_id": {
|
|
529
|
+
"name": "template_id",
|
|
530
|
+
"type": "integer",
|
|
531
|
+
"primaryKey": false,
|
|
532
|
+
"notNull": false,
|
|
533
|
+
"autoincrement": false
|
|
534
|
+
},
|
|
535
|
+
"scheduled_at": {
|
|
536
|
+
"name": "scheduled_at",
|
|
537
|
+
"type": "integer",
|
|
538
|
+
"primaryKey": false,
|
|
539
|
+
"notNull": false,
|
|
540
|
+
"autoincrement": false
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
"indexes": {
|
|
544
|
+
"tasks_queue_idx": {
|
|
545
|
+
"name": "tasks_queue_idx",
|
|
546
|
+
"columns": [
|
|
547
|
+
"status",
|
|
548
|
+
"retry_after",
|
|
549
|
+
"urgency",
|
|
550
|
+
"importance",
|
|
551
|
+
"created_at",
|
|
552
|
+
"id"
|
|
553
|
+
],
|
|
554
|
+
"isUnique": false
|
|
555
|
+
},
|
|
556
|
+
"tasks_batch_status_idx": {
|
|
557
|
+
"name": "tasks_batch_status_idx",
|
|
558
|
+
"columns": [
|
|
559
|
+
"batch_id",
|
|
560
|
+
"status"
|
|
561
|
+
],
|
|
562
|
+
"isUnique": false
|
|
563
|
+
},
|
|
564
|
+
"tasks_template_status_idx": {
|
|
565
|
+
"name": "tasks_template_status_idx",
|
|
566
|
+
"columns": [
|
|
567
|
+
"template_id",
|
|
568
|
+
"status"
|
|
569
|
+
],
|
|
570
|
+
"isUnique": false
|
|
571
|
+
},
|
|
572
|
+
"tasks_depends_on_status_idx": {
|
|
573
|
+
"name": "tasks_depends_on_status_idx",
|
|
574
|
+
"columns": [
|
|
575
|
+
"depends_on",
|
|
576
|
+
"status"
|
|
577
|
+
],
|
|
578
|
+
"isUnique": false
|
|
579
|
+
},
|
|
580
|
+
"tasks_cleanup_idx": {
|
|
581
|
+
"name": "tasks_cleanup_idx",
|
|
582
|
+
"columns": [
|
|
583
|
+
"finished_at",
|
|
584
|
+
"id",
|
|
585
|
+
"status"
|
|
586
|
+
],
|
|
587
|
+
"isUnique": false
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
"foreignKeys": {},
|
|
591
|
+
"compositePrimaryKeys": {},
|
|
592
|
+
"uniqueConstraints": {},
|
|
593
|
+
"checkConstraints": {}
|
|
594
|
+
}
|
|
595
|
+
},
|
|
596
|
+
"views": {},
|
|
597
|
+
"enums": {},
|
|
598
|
+
"_meta": {
|
|
599
|
+
"schemas": {},
|
|
600
|
+
"tables": {},
|
|
601
|
+
"columns": {}
|
|
602
|
+
},
|
|
603
|
+
"internal": {
|
|
604
|
+
"indexes": {}
|
|
605
|
+
}
|
|
606
|
+
}
|