|
| 1 | +import { AdminForthDataTypes } from 'adminforth'; |
| 2 | +import type { AdminForthResourceInput, AdminUser } from 'adminforth'; |
| 3 | +import AutoRemovePlugin from '@adminforth/auto-remove'; |
| 4 | + |
| 5 | +async function allowedForSuperAdmins({ adminUser }: { adminUser: AdminUser }): Promise<boolean> { |
| 6 | + return adminUser.dbUser.role === 'superadmin'; |
| 7 | +} |
| 8 | + |
| 9 | +const checkpointsResource: AdminForthResourceInput = { |
| 10 | + dataSource: 'maindb', |
| 11 | + table: 'agent_checkpoints', |
| 12 | + resourceId: 'agent_checkpoints', |
| 13 | + label: 'Agent Checkpoints', |
| 14 | + columns: [ |
| 15 | + { |
| 16 | + name: 'id', |
| 17 | + primaryKey: true, |
| 18 | + type: AdminForthDataTypes.STRING, |
| 19 | + showIn: { |
| 20 | + edit: false, |
| 21 | + create: false, |
| 22 | + }, |
| 23 | + }, |
| 24 | + { |
| 25 | + name: 'thread_id', |
| 26 | + type: AdminForthDataTypes.STRING, |
| 27 | + }, |
| 28 | + { |
| 29 | + name: 'checkpoint_namespace', |
| 30 | + type: AdminForthDataTypes.STRING, |
| 31 | + }, |
| 32 | + { |
| 33 | + name: 'checkpoint_id', |
| 34 | + type: AdminForthDataTypes.STRING, |
| 35 | + }, |
| 36 | + { |
| 37 | + name: 'parent_checkpoint_id', |
| 38 | + type: AdminForthDataTypes.STRING, |
| 39 | + }, |
| 40 | + { |
| 41 | + name: 'row_kind', |
| 42 | + type: AdminForthDataTypes.STRING, |
| 43 | + }, |
| 44 | + { |
| 45 | + name: 'task_id', |
| 46 | + type: AdminForthDataTypes.STRING, |
| 47 | + }, |
| 48 | + { |
| 49 | + name: 'sequence', |
| 50 | + type: AdminForthDataTypes.INTEGER, |
| 51 | + }, |
| 52 | + { |
| 53 | + name: 'created_at', |
| 54 | + type: AdminForthDataTypes.DATETIME, |
| 55 | + showIn: { |
| 56 | + edit: false, |
| 57 | + create: false, |
| 58 | + }, |
| 59 | + }, |
| 60 | + { |
| 61 | + name: 'checkpoint_payload', |
| 62 | + type: AdminForthDataTypes.TEXT, |
| 63 | + }, |
| 64 | + { |
| 65 | + name: 'metadata_payload', |
| 66 | + type: AdminForthDataTypes.TEXT, |
| 67 | + }, |
| 68 | + { |
| 69 | + name: 'writes_payload', |
| 70 | + type: AdminForthDataTypes.TEXT, |
| 71 | + }, |
| 72 | + { |
| 73 | + name: 'schema_version', |
| 74 | + type: AdminForthDataTypes.INTEGER, |
| 75 | + }, |
| 76 | + ], |
| 77 | + plugins: [ |
| 78 | + new AutoRemovePlugin({ |
| 79 | + createdAtField: 'created_at', |
| 80 | + mode: 'time-based', |
| 81 | + deleteOlderThan: '3d', |
| 82 | + interval: '1d', |
| 83 | + }), |
| 84 | + ], |
| 85 | + options: { |
| 86 | + allowedActions: { |
| 87 | + list: allowedForSuperAdmins, |
| 88 | + show: allowedForSuperAdmins, |
| 89 | + create: false, |
| 90 | + edit: false, |
| 91 | + delete: false, |
| 92 | + }, |
| 93 | + }, |
| 94 | +}; |
| 95 | + |
| 96 | +export default checkpointsResource; |
0 commit comments