generated from template/apps-template
update
This commit is contained in:
3
agents/app.ts
Normal file
3
agents/app.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { QueryRouterServer } from "@kevisual/router";
|
||||
import { useContextKey } from "@kevisual/context";
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
const frontend = 'git@git.xiongxiao.me:template/astro-simple-template.git';
|
||||
const backend = 'git@git.xiongxiao.me:template/router-template.git';
|
||||
|
||||
|
||||
// submodule add frontend to frontend and backend to backend
|
||||
export const cliInitSubmodules = [
|
||||
`git submodule add ${frontend} frontend`,
|
||||
`git submodule add ${backend} backend`,
|
||||
];
|
||||
|
||||
cliInitSubmodules.forEach((cmd) => {
|
||||
console.log(`${cmd}\n`);
|
||||
});
|
||||
|
||||
// init submodules
|
||||
export const cliUpdateSubmodules = `git submodule update --init --recursive`;
|
||||
console.log(`${cliUpdateSubmodules}\n`);
|
||||
|
||||
// 清理submodule,保留模板的内容
|
||||
export const cliRemoveGitModule = `rm .gitmodules -rf && rm -rf .git/modules`;
|
||||
console.log(`${cliRemoveGitModule}\n`);
|
||||
5
agents/modules/query.ts
Normal file
5
agents/modules/query.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { Query } from '@kevisual/query'
|
||||
|
||||
export const query = new Query({
|
||||
url: 'https://kevisual.cn/api/router',
|
||||
})
|
||||
121
agents/noco/common/base-table.ts
Normal file
121
agents/noco/common/base-table.ts
Normal file
@@ -0,0 +1,121 @@
|
||||
import { CreateColumnData } from "@kevisual/noco"
|
||||
export const columns: CreateColumnData[] = [
|
||||
|
||||
{
|
||||
title: 'Id',
|
||||
// @ts-ignore
|
||||
uidt: "ID",
|
||||
pk: true,
|
||||
dt: "int4",
|
||||
dtx: "integer"
|
||||
},
|
||||
{
|
||||
|
||||
title: '标题',
|
||||
uidt: 'SingleLineText',
|
||||
description: '简单的标题',
|
||||
},
|
||||
{
|
||||
title: '标签',
|
||||
uidt: 'MultiSelect',
|
||||
description: '标签分类,对每一条数据的标签定义,快速分类和筛选',
|
||||
},
|
||||
{
|
||||
title: '总结',
|
||||
uidt: 'LongText',
|
||||
description: '概览性总结',
|
||||
},
|
||||
{
|
||||
title: '描述',
|
||||
uidt: 'LongText',
|
||||
description: '长文本描述',
|
||||
},
|
||||
{
|
||||
title: '数据',
|
||||
uidt: 'JSON',
|
||||
description: '扩列数据,存储更多的自定义信息',
|
||||
},
|
||||
{
|
||||
title: '链接',
|
||||
uidt: 'URL',
|
||||
description: '快速跳转链接,默认为空,比如我这里是一个人生日程的链接,在外部打开',
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
uidt: 'SingleSelect',
|
||||
description: '任务类型:备忘和其他,如果是备忘,只做记录,如果是其他的,属于任务管理,到达对应的时间,进行任务提醒,归档是自己不再查询。',
|
||||
cdf: '备忘',
|
||||
colOptions: {
|
||||
// 每日,每周,每月,每年,一次性,备忘,归档,智能
|
||||
options: [
|
||||
{
|
||||
title: '每日',
|
||||
},
|
||||
{
|
||||
title: '每周',
|
||||
},
|
||||
{
|
||||
title: '每月',
|
||||
},
|
||||
{
|
||||
title: '每年',
|
||||
},
|
||||
{
|
||||
title: '每年农历',
|
||||
},
|
||||
{
|
||||
title: '备忘',
|
||||
},
|
||||
{
|
||||
title: '归档',
|
||||
},
|
||||
{
|
||||
title: '智能',
|
||||
},
|
||||
]
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '启动时间',
|
||||
description: '任务启动的时间点, 下次启动的时间点。到达当天,显示当天的任务,然后如果执行了,如果是循环周期任务,更新下次启动时间。',
|
||||
uidt: 'DateTime',
|
||||
},
|
||||
{
|
||||
title: '任务',
|
||||
uidt: 'MultiSelect',
|
||||
description: '任务状态,如果是任务,需要判断运行还是非运行中',
|
||||
cdf: '非任务',
|
||||
colOptions: {
|
||||
// 非任务, 运行中,已停止,个人计划,已完成
|
||||
options: [
|
||||
{
|
||||
title: '非任务',
|
||||
},
|
||||
{
|
||||
title: '运行中',
|
||||
},
|
||||
{
|
||||
title: '已停止',
|
||||
},
|
||||
{
|
||||
title: '个人计划',
|
||||
},
|
||||
{
|
||||
title: '已完成',
|
||||
},
|
||||
{
|
||||
title: 'AI自动化'
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '任务结果',
|
||||
description: '任务结果描述, 执行后回馈',
|
||||
uidt: 'LongText'
|
||||
},
|
||||
{
|
||||
title: '提示词',
|
||||
uidt: 'LongText',
|
||||
description: '和AI交互时候简单的实时提示词',
|
||||
}]
|
||||
91
agents/noco/common/core.ts
Normal file
91
agents/noco/common/core.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
import { NocoApi } from "@kevisual/noco";
|
||||
import { columns } from "../common/base-table.ts";
|
||||
|
||||
type ReponseData<T = {}> = {
|
||||
code: number,
|
||||
message?: string,
|
||||
data?: T
|
||||
}
|
||||
export type CoreOptions<T = {}> = {
|
||||
nocoApi: NocoApi,
|
||||
baseId?: string
|
||||
} & T
|
||||
|
||||
type CoreItem = {
|
||||
Id: number,
|
||||
标题: string,
|
||||
总结?: string,
|
||||
启动时间?: string,
|
||||
标签?: string,
|
||||
任务?: string, // 运行中,已完成,未开始
|
||||
链接?: string,
|
||||
数据?: string,
|
||||
类型?: string,
|
||||
提示词?: string,
|
||||
任务结果?: string,
|
||||
}
|
||||
export class Core {
|
||||
nocoApi: NocoApi;
|
||||
baseId?: string;
|
||||
key = 'core';
|
||||
title = '默认表';
|
||||
description = '默认表描述';
|
||||
tableId?: string;
|
||||
constructor(opts: {
|
||||
nocoApi: NocoApi,
|
||||
baseId?: string,
|
||||
tableId?: string
|
||||
}) {
|
||||
this.nocoApi = opts.nocoApi;
|
||||
this.baseId = opts.baseId;
|
||||
this.tableId = opts.tableId;
|
||||
}
|
||||
async createTable(opts?: { columns?: any[], title?: string, description?: string, baseId?: string }): Promise<ReponseData<{ id: string, title: string }>> {
|
||||
const baseId = opts?.baseId ?? this.baseId!;
|
||||
const title = opts?.title ?? this.title;
|
||||
const description = opts?.description ?? this.description;
|
||||
const _columns = opts?.columns ?? columns;
|
||||
let tableId = '';
|
||||
const res = await this.nocoApi.meta.tables.createTable(baseId, {
|
||||
title,
|
||||
description,
|
||||
columns: _columns,
|
||||
})
|
||||
let code = 200;
|
||||
if (res.code !== 200) {
|
||||
const res = await this.nocoApi.meta.tables.list(baseId);
|
||||
const list = res.data?.list || [];
|
||||
const existTable = list.find(t => t.title === title);
|
||||
if (existTable) {
|
||||
tableId = existTable.id;
|
||||
} else {
|
||||
return {
|
||||
code: res.code,
|
||||
message: `创建表失败,且未找到同名表`,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tableId = res?.data?.id;
|
||||
}
|
||||
this.tableId = tableId;
|
||||
return {
|
||||
code,
|
||||
data: {
|
||||
id: tableId,
|
||||
title,
|
||||
}
|
||||
};
|
||||
}
|
||||
getItem(id: number): Promise<ReponseData<CoreItem>> {
|
||||
return this.nocoApi.record.read(id);
|
||||
}
|
||||
|
||||
getList(params: any): Promise<ReponseData<{ list: CoreItem[] }>> {
|
||||
return this.nocoApi.record.list({
|
||||
...params,
|
||||
});
|
||||
}
|
||||
updateItem(data: Partial<CoreItem>) {
|
||||
return this.nocoApi.record.update(data);
|
||||
}
|
||||
}
|
||||
2
agents/noco/common/index.ts
Normal file
2
agents/noco/common/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./core.ts";
|
||||
export * from "./base-table.ts";
|
||||
8
agents/noco/control/index.ts
Normal file
8
agents/noco/control/index.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { NocoApi } from "@kevisual/noco";
|
||||
import { Core } from "../common/index.ts";
|
||||
|
||||
export class Control extends Core {
|
||||
key = 'control';
|
||||
title = '控制中枢'
|
||||
description = '管理和控制系统的运行'
|
||||
}
|
||||
11
agents/noco/index.ts
Normal file
11
agents/noco/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { NocoApi } from "@kevisual/noco";
|
||||
import { columns } from "./common/base-table.ts";
|
||||
import { Life } from "../noco/life/index.ts";
|
||||
import { Control } from "../noco/control/index.ts";
|
||||
|
||||
export {
|
||||
NocoApi,
|
||||
columns,
|
||||
Control,
|
||||
Life
|
||||
}
|
||||
8
agents/noco/life/index.ts
Normal file
8
agents/noco/life/index.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { NocoApi } from "@kevisual/noco";
|
||||
import { Core } from "../common/index.ts";
|
||||
|
||||
export class Life extends Core {
|
||||
key = 'life';
|
||||
title = '人生备忘录'
|
||||
description = '记录和管理你的人生大事小事'
|
||||
}
|
||||
108
agents/query/query-config.ts
Normal file
108
agents/query/query-config.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
import { Query } from '@kevisual/query';
|
||||
import type { Result } from '@kevisual/query/query';
|
||||
type QueryConfigOpts = {
|
||||
query?: Query;
|
||||
};
|
||||
export type Config<T = any> = {
|
||||
id?: string;
|
||||
title?: string;
|
||||
key?: string;
|
||||
description?: string;
|
||||
data?: T;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
};
|
||||
export type UploadConfig = {
|
||||
key?: string;
|
||||
version?: string;
|
||||
};
|
||||
type PostOpts = {
|
||||
token?: string;
|
||||
};
|
||||
export const defaultConfigKeys = ['upload.json', 'workspace.json', 'ai.json', 'user.json', 'life.json'] as const;
|
||||
type DefaultConfigKey = (typeof defaultConfigKeys)[number];
|
||||
|
||||
export class QueryConfig {
|
||||
query: Query;
|
||||
constructor(opts?: QueryConfigOpts) {
|
||||
this.query = opts?.query || new Query();
|
||||
}
|
||||
async post<T = Config>(data: any) {
|
||||
return this.query.post<T>({ path: 'config', ...data });
|
||||
}
|
||||
async getConfig({ id, key }: { id?: string; key?: string }, opts?: PostOpts) {
|
||||
return this.post({
|
||||
key: 'get',
|
||||
data: {
|
||||
id,
|
||||
key,
|
||||
},
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
async updateConfig(data: Config, opts?: PostOpts) {
|
||||
return this.post({
|
||||
key: 'update',
|
||||
data,
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
async deleteConfig(id: string, opts?: PostOpts) {
|
||||
return this.post({
|
||||
key: 'delete',
|
||||
data: { id },
|
||||
});
|
||||
}
|
||||
async listConfig(opts?: PostOpts) {
|
||||
return this.post<{ list: Config[] }>({
|
||||
key: 'list',
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 获取上传配置
|
||||
* @returns
|
||||
*/
|
||||
async getUploadConfig(opts?: PostOpts) {
|
||||
return this.post<Result<Config<UploadConfig>>>({
|
||||
key: 'getUploadConfig',
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 更新上传配置
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
async updateUploadConfig(data: Config, opts?: PostOpts) {
|
||||
return this.post<Result<Config<UploadConfig>>>({
|
||||
key: 'updateUploadConfig',
|
||||
data,
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测配置是否存在
|
||||
* @param id
|
||||
* @returns
|
||||
*/
|
||||
async detectConfig(opts?: PostOpts) {
|
||||
return this.post<{ updateList: Config[] }>({
|
||||
key: 'detect',
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 获取配置, 获取默认的配置项
|
||||
* @param key
|
||||
* @returns
|
||||
*/
|
||||
async getConfigByKey(key: DefaultConfigKey, opts?: PostOpts) {
|
||||
return this.post<Result<Config>>({
|
||||
key: 'defaultConfig',
|
||||
configKey: key,
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user