diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml new file mode 100644 index 00000000..3f7b32eb --- /dev/null +++ b/.github/workflows/cli.yml @@ -0,0 +1,40 @@ +name: cli CI + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +defaults: + run: + working-directory: data-agent-cli + +jobs: + lint: + name: Lint & Format Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: data-agent-cli/package-lock.json + - run: npm ci + - run: npm run lint:check + - run: npm run format:check + + build: + name: Build & Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + cache-dependency-path: data-agent-cli/package-lock.json + - run: npm ci + - run: npm run build + - run: npm test diff --git a/README.md b/README.md index cc92900d..7e8cf33d 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ - **资产与数据证据**:内置报表、CSV 导出与数据证据视图,记录回答涉及的 SQL、指标、Python 执行及表列来源。 - **Skill 系统**:从文件系统 / Git / Nacos 多源加载可复用的查询流程("已验证查询模式")。 - **MCP 配置管理(开发中)**:提供外部 MCP Server 的配置增删改查与启停状态管理;当前尚未将外部 MCP 工具接入 Agent 工具箱。 +- **外部 Agent 接入**:可直接通过 npm 安装 `data-agent-cli`,并提供可直接复制到 Claude Code、Codex、Cursor、OpenCode 等 Skill 目录的 `data-agent-skill/`。 - **可观测性(OpenTelemetry)**:HTTP、Agent、LLM、工具与 JDBC 调用统一走 OTel trace;标准 OTLP 导出,可接入任意 OTel 后端(Jaeger / Tempo / SigNoz / Langfuse 等),仓库自带 Grafana LGTM 本地示例。 ## 💡 核心设计亮点 @@ -77,6 +78,30 @@ Data Agent 反其道而行——**不引入任何向量检索**。语义层把 详见 [docs/observability.md](docs/observability.md)。 +## 🤖 外部 Agent 接入 + +Data Agent 支持面向外部 Agent 的只读接入: + +- 用户在「API 访问令牌」页面(`/settings/tokens`)创建 PAT +- 通过 `/agent/health`、`/agent/tools`、`/agent/tools/{name}` 调用只读工具 +- 使用 `data-agent-cli` 完成登录、工具发现和工具调用 +- 将 `data-agent-skill/` 复制到外部 Agent 的 Skill 存储目录,即可安装问数 Skill + +```bash +npm install -g @malone-talk/data-agent-cli +data-agent-cli auth login --token pat_xxx +data-agent-cli tools list +data-agent-cli skill +``` + +外部 Agent 可按自身约定复制 Skill: + +```bash +cp -R data-agent-skill / +``` + +当前对外暴露 `get_datasources`、`get_domains`、`get_tables`、`get_table_schema`、`get_metric_caliber` 和 `execute_sql`,`execute_sql` 只允许 SELECT。完整说明见 [docs/external-agent.md](docs/external-agent.md)。 + ## 🚀 快速开始 > Docker 与手动搭建步骤见 [docs/getting-started.md](docs/getting-started.md)。以下命令使用 Bash;Windows PowerShell 的环境变量写法见该文档。 diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/AgentService.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/AgentService.java index 34f860e2..ab3a7bb0 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/AgentService.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/AgentService.java @@ -35,7 +35,7 @@ import io.github.malonetalk.agent.models.ModelProperties; import io.github.malonetalk.agent.provenance.AnswerProvenanceService; import io.github.malonetalk.agent.skill.SkillLoaderService; -import io.github.malonetalk.agent.tools.MarkAgentTool; +import io.github.malonetalk.agent.tools.DataAgentTool; import io.github.malonetalk.agent.tools.ToolCallConstants; import io.github.malonetalk.convertor.EventConverter; import io.github.malonetalk.dto.ChatRequest; @@ -77,7 +77,7 @@ public class AgentService { private static final ZoneId DEFAULT_ZONE = ZoneId.of("Asia/Shanghai"); private final ModelFactory modelFactory; - private final List allToolBeans; + private final List allToolBeans; private final ModelProperties modelProperties; private final SessionService sessionService; private final SessionDatasourceService sessionDatasourceService; diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/AgentToolController.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/AgentToolController.java new file mode 100644 index 00000000..9b6aecd3 --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/AgentToolController.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.agent; + +import io.github.malonetalk.agent.tools.AgentToolInvoker; +import io.github.malonetalk.exception.BusinessException; +import io.github.malonetalk.exception.ErrorCode; +import io.github.malonetalk.interceptor.AgentAuthInterceptor; +import io.github.malonetalk.model.bo.ToolResultBo; +import io.github.malonetalk.model.bo.UserPatBo; +import io.github.malonetalk.model.converter.UserPatConverter; +import io.github.malonetalk.model.holder.UserContextHolder; +import io.github.malonetalk.model.vo.AgentToolVo; +import io.github.malonetalk.model.vo.ListVo; +import io.github.malonetalk.model.vo.ToolResultVo; +import io.github.malonetalk.model.vo.UserPatVo; +import io.github.malonetalk.service.DataPermissionService; +import io.micrometer.tracing.Tracer; +import jakarta.servlet.http.HttpServletRequest; +import java.util.Map; +import java.util.Optional; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@AllArgsConstructor +@Slf4j +@RequestMapping("/agent") +public class AgentToolController { + + private static final String SESSION_ID_HEADER = "X-Session-Id"; + private static final String CLIENT_AGENT_CODE = "CLIENT"; + private static final String DEFAULT_SESSION = "__default__"; + + private final AgentToolInvoker invoker; + private final DataPermissionService dataPermissions; + private final UserContextHolder userContextHolder; + private final UserPatConverter userPatConverter; + private final Tracer tracer; + + @GetMapping("/health") + public UserPatVo health(HttpServletRequest request) { + UserPatBo pat = + Optional.ofNullable( + (UserPatBo) + request.getAttribute( + AgentAuthInterceptor.AUTHENTICATED_PAT_ATTRIBUTE)) + .orElseThrow(() -> BusinessException.of(ErrorCode.UNAUTHORIZED)); + return userPatConverter.toVo(pat); + } + + @GetMapping("/tools") + public ListVo listTools() { + return new ListVo<>( + invoker.list().stream() + .map( + tool -> + new AgentToolVo( + tool.name(), tool.description(), tool.parameters())) + .toList()); + } + + @PostMapping("/tools/{name}") + public ToolResultVo callTool( + @PathVariable String name, + @RequestBody(required = false) Map input, + HttpServletRequest request) { + var user = userContextHolder.checkAndGet(); + Map params = input == null ? Map.of() : input; + String externalSessionId = + Optional.ofNullable(request.getHeader(SESSION_ID_HEADER)) + .map(String::trim) + .orElse(DEFAULT_SESSION); + String sessionId = + SessionIdFactory.build(CLIENT_AGENT_CODE, user.userId(), externalSessionId); + ToolCallContext context = + ToolCallContext.builder() + .sessionId(sessionId) + .userId(user.userId()) + .datasourceIds( + dataPermissions.accessibleDatasourceIds(user).stream() + .sorted() + .toList()) + .build(); + + long startedAt = System.nanoTime(); + ToolResultBo result = invoker.invoke(name, params, context); + long durationMs = (System.nanoTime() - startedAt) / 1_000_000; + String traceId = currentTraceId(); + log.info( + "Agent tool call: tool={}, userId={}, sessionId={}, durationMs={}, traceId={}", + name, + user.userId(), + sessionId, + durationMs, + traceId); + return new ToolResultVo(result.text(), result.metadata(), traceId); + } + + private String currentTraceId() { + var span = tracer.currentSpan(); + return span == null ? null : span.context().traceId(); + } +} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/AgentToolInvoker.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/AgentToolInvoker.java new file mode 100644 index 00000000..7be590cd --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/AgentToolInvoker.java @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.agent.tools; + +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.agentscope.core.tool.Tool; +import io.agentscope.core.tool.ToolParam; +import io.agentscope.core.util.JsonSchemaUtils; +import io.github.malonetalk.agent.ToolCallContext; +import io.github.malonetalk.exception.BusinessException; +import io.github.malonetalk.exception.ErrorCode; +import io.github.malonetalk.model.bo.AgentToolDefinitionBo; +import io.github.malonetalk.model.bo.ToolResultBo; +import jakarta.annotation.PostConstruct; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** 反射调用通过 {@link RestTool} 暴露的工具方法,并直接返回 {@link ToolResultBo}。 */ +@Slf4j +@Component +@RequiredArgsConstructor +public class AgentToolInvoker { + + private final List tools; + private final ObjectMapper objectMapper; + private final Map exposed = new LinkedHashMap<>(); + private volatile List definitions = List.of(); + + @PostConstruct + void init() { + for (DataAgentTool bean : tools) { + bean.restToolMethods().forEach(method -> register(bean, method)); + } + // 工具 Bean 只会在启动时注册一次,列表定义无需每次请求重新生成。 + definitions = exposed.values().stream().map(this::definition).toList(); + log.info("Registered {} REST agent tools: {}", exposed.size(), exposed.keySet()); + } + + public List list() { + return definitions; + } + + public ToolResultBo invoke(String name, Map input, ToolCallContext context) { + ExposedTool tool = + Optional.ofNullable(exposed.get(name)) + .orElseThrow( + () -> + BusinessException.of( + ErrorCode.RESOURCE_NOT_FOUND, + "Tool not found: " + name)); + + Object[] arguments = new Object[tool.method().getParameterCount()]; + for (BoundParameter parameter : tool.parameters()) { + if (parameter.type() == ToolCallContext.class) { + arguments[parameter.index()] = context; + continue; + } + Object value = input == null ? null : input.get(parameter.name()); + if (value == null) { + if (parameter.required()) { + throw BusinessException.of( + ErrorCode.BAD_REQUEST, "Missing parameter: " + parameter.name()); + } + arguments[parameter.index()] = null; + continue; + } + JavaType javaType = objectMapper.getTypeFactory().constructType(parameter.type()); + arguments[parameter.index()] = objectMapper.convertValue(value, javaType); + } + + try { + Object result = tool.method().invoke(tool.bean(), arguments); + if (result instanceof ToolResultBo toolResult) { + return toolResult; + } + throw new IllegalStateException( + "Tool method must return ToolResultBo: " + tool.method()); + } catch (InvocationTargetException e) { + Throwable cause = e.getCause(); + if (cause instanceof RuntimeException runtimeException) { + throw runtimeException; + } + throw new IllegalStateException(cause); + } catch (IllegalAccessException e) { + throw new IllegalStateException(e); + } + } + + private void register(DataAgentTool bean, Method method) { + Tool tool = method.getAnnotation(Tool.class); + if (tool == null) { + throw new IllegalStateException("@RestTool method must also have @Tool: " + method); + } + method.setAccessible(true); + String name = tool.name().isBlank() ? method.getName() : tool.name(); + ExposedTool existing = + exposed.putIfAbsent( + name, new ExposedTool(bean, method, tool, bindParameters(method))); + if (existing != null) { + throw new IllegalStateException("Duplicate REST tool name: " + name); + } + } + + private List bindParameters(Method method) { + Parameter[] parameters = method.getParameters(); + List bound = new ArrayList<>(parameters.length); + for (int index = 0; index < parameters.length; index++) { + Parameter parameter = parameters[index]; + if (parameter.getType() == ToolCallContext.class) { + bound.add(new BoundParameter(null, false, parameter.getType(), index, null)); + continue; + } + ToolParam toolParam = parameter.getAnnotation(ToolParam.class); + if (toolParam == null) { + throw new IllegalStateException( + "Tool parameter must be annotated with @ToolParam: " + parameter); + } + bound.add( + new BoundParameter( + toolParam.name(), + toolParam.required(), + parameter.getParameterizedType(), + index, + toolParam.description())); + } + return bound; + } + + private AgentToolDefinitionBo definition(ExposedTool tool) { + Map properties = new LinkedHashMap<>(); + List required = new ArrayList<>(); + for (BoundParameter parameter : tool.parameters()) { + if (parameter.type() == ToolCallContext.class) { + continue; + } + Map schema = JsonSchemaUtils.generateSchemaFromType(parameter.type()); + if (parameter.description() != null && !parameter.description().isBlank()) { + schema.put("description", parameter.description()); + } + properties.put(parameter.name(), schema); + if (parameter.required()) { + required.add(parameter.name()); + } + } + + Map parameters = new LinkedHashMap<>(); + parameters.put("type", "object"); + parameters.put("properties", properties); + if (!required.isEmpty()) { + parameters.put("required", required); + } + + String description = + tool.tool().description().isBlank() + ? "Tool: " + tool.name() + : tool.tool().description(); + return new AgentToolDefinitionBo(tool.name(), description, parameters); + } + + private record BoundParameter( + String name, boolean required, Type type, int index, String description) {} + + private record ExposedTool( + DataAgentTool bean, Method method, Tool tool, List parameters) { + String name() { + return tool.name().isBlank() ? method.getName() : tool.name(); + } + } +} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/DataAgentTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/DataAgentTool.java new file mode 100644 index 00000000..79d7de68 --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/DataAgentTool.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.agent.tools; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.List; +import org.springframework.util.ClassUtils; + +public interface DataAgentTool { + + /** + * 返回暴露为 REST 的工具方法;空列表表示仅 Agent 内部调用。 + * + *

默认从当前工具类中查找带 {@link RestTool} 的方法,具体工具类不需要覆写。 + * 与 AgentScope 一致,一个工具类可以声明多个 {@code @Tool} / {@code @RestTool} 方法。 + */ + default List restToolMethods() { + Class type = ClassUtils.getUserClass(getClass()); + return Arrays.stream(type.getDeclaredMethods()) + .filter(method -> method.isAnnotationPresent(RestTool.class)) + .toList(); + } +} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/RestTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/RestTool.java new file mode 100644 index 00000000..7e0a7129 --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/RestTool.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.agent.tools; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** 标记某个 {@code @Tool} 方法同时暴露为 REST 工具。 */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface RestTool {} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/AskUserTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/AskUserTool.java similarity index 85% rename from data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/AskUserTool.java rename to data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/AskUserTool.java index e66736d7..652ee936 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/AskUserTool.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/AskUserTool.java @@ -15,18 +15,21 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import io.agentscope.core.tool.Tool; import io.agentscope.core.tool.ToolParam; import io.agentscope.core.tool.ToolSuspendException; +import io.github.malonetalk.agent.tools.DataAgentTool; +import io.github.malonetalk.agent.tools.ToolCallConstants; +import io.github.malonetalk.agent.tools.ToolResultBoConverter; import io.github.malonetalk.model.bo.ToolResultBo; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @Slf4j @Component -public class AskUserTool implements MarkAgentTool { +public class AskUserTool implements DataAgentTool { @Tool( name = ToolCallConstants.ASK_USER, diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/DateInfoTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/DateInfoTool.java similarity index 96% rename from data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/DateInfoTool.java rename to data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/DateInfoTool.java index fe46f7c3..27eee6ef 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/DateInfoTool.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/DateInfoTool.java @@ -15,12 +15,15 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.ObjectMapper; import io.agentscope.core.tool.Tool; import io.agentscope.core.tool.ToolParam; +import io.github.malonetalk.agent.tools.DataAgentTool; +import io.github.malonetalk.agent.tools.ToolExceptionMapper; +import io.github.malonetalk.agent.tools.ToolResultBoConverter; import io.github.malonetalk.exception.ExceptionResponseMapper; import io.github.malonetalk.model.bo.ToolResultBo; import java.io.IOException; @@ -47,7 +50,7 @@ @Component @AllArgsConstructor(access = AccessLevel.PRIVATE) -public class DateInfoTool implements MarkAgentTool { +public class DateInfoTool implements DataAgentTool { private static final String DEFAULT_TIMEZONE = "Asia/Shanghai"; private static final String HOLIDAY_API_BASE_URL = "https://timor.tech/api/holiday/info"; diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/ExecutePythonTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/ExecutePythonTool.java similarity index 95% rename from data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/ExecutePythonTool.java rename to data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/ExecutePythonTool.java index 89a499df..eeead5bd 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/ExecutePythonTool.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/ExecutePythonTool.java @@ -15,11 +15,14 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import io.agentscope.core.tool.Tool; import io.agentscope.core.tool.ToolParam; import io.github.malonetalk.agent.ToolCallContext; +import io.github.malonetalk.agent.tools.DataAgentTool; +import io.github.malonetalk.agent.tools.ToolExceptionMapper; +import io.github.malonetalk.agent.tools.ToolResultBoConverter; import io.github.malonetalk.enums.PermissionEnum; import io.github.malonetalk.model.bo.ToolResultBo; import io.github.malonetalk.service.PermissionService; @@ -38,7 +41,7 @@ @RequiredArgsConstructor @Slf4j @Component -public class ExecutePythonTool implements MarkAgentTool { +public class ExecutePythonTool implements DataAgentTool { private final PermissionService permissions; private final ToolExceptionMapper toolExceptionMapper; diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/ExecuteSqlTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/ExecuteSqlTool.java similarity index 91% rename from data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/ExecuteSqlTool.java rename to data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/ExecuteSqlTool.java index caf182ce..7555993c 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/ExecuteSqlTool.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/ExecuteSqlTool.java @@ -15,7 +15,7 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -25,6 +25,11 @@ import io.github.malonetalk.agent.datasource.QueryResult; import io.github.malonetalk.agent.datasource.SqlExecutor; import io.github.malonetalk.agent.datasource.SqlExecutor.SqlExecution; +import io.github.malonetalk.agent.tools.DataAgentTool; +import io.github.malonetalk.agent.tools.RestTool; +import io.github.malonetalk.agent.tools.ToolDatasourceResolver; +import io.github.malonetalk.agent.tools.ToolExceptionMapper; +import io.github.malonetalk.agent.tools.ToolResultBoConverter; import io.github.malonetalk.model.bo.SqlToolMetadataBo; import io.github.malonetalk.model.bo.ToolResultBo; import io.github.malonetalk.model.po.DatasourcePo; @@ -34,13 +39,14 @@ @Component @AllArgsConstructor -public class ExecuteSqlTool implements MarkAgentTool { +public class ExecuteSqlTool implements DataAgentTool { private final ToolDatasourceResolver datasourceResolver; private final SqlExecutor sqlExecutor; private final ToolExceptionMapper toolExceptionMapper; private final ObjectMapper objectMapper; + @RestTool @Tool( name = "execute_sql", converter = ToolResultBoConverter.class, diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/ExportTableTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/ExportTableTool.java similarity index 92% rename from data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/ExportTableTool.java rename to data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/ExportTableTool.java index e867924a..10a72dc9 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/ExportTableTool.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/ExportTableTool.java @@ -15,13 +15,18 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import io.agentscope.core.tool.Tool; import io.agentscope.core.tool.ToolParam; import io.github.malonetalk.agent.ToolCallContext; +import io.github.malonetalk.agent.tools.DataAgentTool; +import io.github.malonetalk.agent.tools.ToolCallConstants; +import io.github.malonetalk.agent.tools.ToolDatasourceResolver; +import io.github.malonetalk.agent.tools.ToolExceptionMapper; +import io.github.malonetalk.agent.tools.ToolResultBoConverter; import io.github.malonetalk.dto.TableExportResponse; import io.github.malonetalk.enums.PermissionEnum; import io.github.malonetalk.model.bo.SqlToolMetadataBo; @@ -35,7 +40,7 @@ @Component @AllArgsConstructor -public class ExportTableTool implements MarkAgentTool { +public class ExportTableTool implements DataAgentTool { private final PermissionService permissions; diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GenerateReportTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GenerateReportTool.java similarity index 93% rename from data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GenerateReportTool.java rename to data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GenerateReportTool.java index b149566b..9e882114 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GenerateReportTool.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GenerateReportTool.java @@ -15,11 +15,15 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import io.agentscope.core.tool.Tool; import io.agentscope.core.tool.ToolParam; import io.github.malonetalk.agent.ToolCallContext; +import io.github.malonetalk.agent.tools.DataAgentTool; +import io.github.malonetalk.agent.tools.ToolCallConstants; +import io.github.malonetalk.agent.tools.ToolExceptionMapper; +import io.github.malonetalk.agent.tools.ToolResultBoConverter; import io.github.malonetalk.enums.PermissionEnum; import io.github.malonetalk.model.bo.ToolResultBo; import io.github.malonetalk.service.PermissionService; @@ -32,7 +36,7 @@ @Slf4j @Component @AllArgsConstructor -public class GenerateReportTool implements MarkAgentTool { +public class GenerateReportTool implements DataAgentTool { private final PermissionService permissions; diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetDatasourcesTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetDatasourcesTool.java similarity index 85% rename from data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetDatasourcesTool.java rename to data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetDatasourcesTool.java index 1fffc006..8a889c6d 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetDatasourcesTool.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetDatasourcesTool.java @@ -15,11 +15,17 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import io.agentscope.core.tool.Tool; import io.agentscope.core.util.JsonUtils; import io.github.malonetalk.agent.ToolCallContext; +import io.github.malonetalk.agent.tools.DataAgentTool; +import io.github.malonetalk.agent.tools.RestTool; +import io.github.malonetalk.agent.tools.ToolCallConstants; +import io.github.malonetalk.agent.tools.ToolDatasourceResolver; +import io.github.malonetalk.agent.tools.ToolExceptionMapper; +import io.github.malonetalk.agent.tools.ToolResultBoConverter; import io.github.malonetalk.model.bo.DatasourceInfoBo; import io.github.malonetalk.model.bo.ToolResultBo; import io.github.malonetalk.model.po.DatasourcePo; @@ -29,11 +35,12 @@ @Component @AllArgsConstructor -public class GetDatasourcesTool implements MarkAgentTool { +public class GetDatasourcesTool implements DataAgentTool { private final ToolDatasourceResolver datasourceResolver; private final ToolExceptionMapper toolExceptionMapper; + @RestTool @Tool( name = ToolCallConstants.GET_DATASOURCES, converter = ToolResultBoConverter.class, diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetDomainsTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetDomainsTool.java similarity index 91% rename from data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetDomainsTool.java rename to data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetDomainsTool.java index 5b23d111..f104323e 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetDomainsTool.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetDomainsTool.java @@ -15,12 +15,17 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import io.agentscope.core.tool.Tool; import io.agentscope.core.tool.ToolParam; import io.agentscope.core.util.JsonUtils; import io.github.malonetalk.agent.ToolCallContext; +import io.github.malonetalk.agent.tools.DataAgentTool; +import io.github.malonetalk.agent.tools.RestTool; +import io.github.malonetalk.agent.tools.ToolDatasourceResolver; +import io.github.malonetalk.agent.tools.ToolExceptionMapper; +import io.github.malonetalk.agent.tools.ToolResultBoConverter; import io.github.malonetalk.enums.PermissionEnum; import io.github.malonetalk.mapper.TableInfoMapper; import io.github.malonetalk.model.bo.ToolResultBo; @@ -36,7 +41,7 @@ @Component @AllArgsConstructor -public class GetDomainsTool implements MarkAgentTool { +public class GetDomainsTool implements DataAgentTool { private final PermissionService permissions; @@ -46,6 +51,7 @@ public class GetDomainsTool implements MarkAgentTool { private final DataPermissionService dataPermissions; private final ToolExceptionMapper toolExceptionMapper; + @RestTool @Tool( name = "get_domains", converter = ToolResultBoConverter.class, diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetMetricCaliberTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetMetricCaliberTool.java similarity index 92% rename from data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetMetricCaliberTool.java rename to data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetMetricCaliberTool.java index 24e8fbc9..6497bbda 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetMetricCaliberTool.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetMetricCaliberTool.java @@ -15,11 +15,16 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import io.agentscope.core.tool.Tool; import io.agentscope.core.tool.ToolParam; import io.github.malonetalk.agent.ToolCallContext; +import io.github.malonetalk.agent.tools.DataAgentTool; +import io.github.malonetalk.agent.tools.RestTool; +import io.github.malonetalk.agent.tools.ToolDatasourceResolver; +import io.github.malonetalk.agent.tools.ToolExceptionMapper; +import io.github.malonetalk.agent.tools.ToolResultBoConverter; import io.github.malonetalk.enums.PermissionEnum; import io.github.malonetalk.model.bo.ToolResultBo; import io.github.malonetalk.model.vo.AnswerProvenanceVo.MetricUse; @@ -31,7 +36,7 @@ @Component @AllArgsConstructor -public class GetMetricCaliberTool implements MarkAgentTool { +public class GetMetricCaliberTool implements DataAgentTool { private final PermissionService permissions; @@ -39,6 +44,7 @@ public class GetMetricCaliberTool implements MarkAgentTool { private final ToolDatasourceResolver datasourceResolver; private final ToolExceptionMapper toolExceptionMapper; + @RestTool @Tool( name = "get_metric_caliber", converter = ToolResultBoConverter.class, diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetTableSchemaTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetTableSchemaTool.java similarity index 89% rename from data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetTableSchemaTool.java rename to data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetTableSchemaTool.java index 68e68c5b..d00ef2fe 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetTableSchemaTool.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetTableSchemaTool.java @@ -15,11 +15,17 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import io.agentscope.core.tool.Tool; import io.agentscope.core.tool.ToolParam; import io.github.malonetalk.agent.ToolCallContext; +import io.github.malonetalk.agent.tools.DataAgentTool; +import io.github.malonetalk.agent.tools.RestTool; +import io.github.malonetalk.agent.tools.ToolCallConstants; +import io.github.malonetalk.agent.tools.ToolDatasourceResolver; +import io.github.malonetalk.agent.tools.ToolExceptionMapper; +import io.github.malonetalk.agent.tools.ToolResultBoConverter; import io.github.malonetalk.dto.prompt.ColumnPromptResponse; import io.github.malonetalk.enums.PermissionEnum; import io.github.malonetalk.model.bo.ToolResultBo; @@ -35,7 +41,7 @@ @Component @AllArgsConstructor -public class GetTableSchemaTool implements MarkAgentTool { +public class GetTableSchemaTool implements DataAgentTool { private final PermissionService permissions; @@ -44,6 +50,7 @@ public class GetTableSchemaTool implements MarkAgentTool { private final ColumnSemanticService columnSemanticService; private final ToolExceptionMapper toolExceptionMapper; + @RestTool @Tool( name = "get_table_schema", converter = ToolResultBoConverter.class, diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetTablesTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetTablesTool.java similarity index 91% rename from data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetTablesTool.java rename to data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetTablesTool.java index 3e73a470..1d18e4cb 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetTablesTool.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/impls/GetTablesTool.java @@ -15,12 +15,18 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import io.agentscope.core.tool.Tool; import io.agentscope.core.tool.ToolParam; import io.agentscope.core.util.JsonUtils; import io.github.malonetalk.agent.ToolCallContext; +import io.github.malonetalk.agent.tools.DataAgentTool; +import io.github.malonetalk.agent.tools.RestTool; +import io.github.malonetalk.agent.tools.ToolCallConstants; +import io.github.malonetalk.agent.tools.ToolDatasourceResolver; +import io.github.malonetalk.agent.tools.ToolExceptionMapper; +import io.github.malonetalk.agent.tools.ToolResultBoConverter; import io.github.malonetalk.dto.prompt.TablePromptResponse; import io.github.malonetalk.enums.PermissionEnum; import io.github.malonetalk.model.bo.DataPermissionScopeBo; @@ -36,7 +42,7 @@ @Component @AllArgsConstructor -public class GetTablesTool implements MarkAgentTool { +public class GetTablesTool implements DataAgentTool { private final PermissionService permissions; @@ -45,6 +51,7 @@ public class GetTablesTool implements MarkAgentTool { private final TableSemanticService tableSemanticService; private final ToolExceptionMapper toolExceptionMapper; + @RestTool @Tool( name = "get_tables", converter = ToolResultBoConverter.class, diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/config/WebMvcConfig.java b/data-agent-backend/src/main/java/io/github/malonetalk/config/WebMvcConfig.java index 211f502e..5dc8cb4c 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/config/WebMvcConfig.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/config/WebMvcConfig.java @@ -17,6 +17,7 @@ */ package io.github.malonetalk.config; +import io.github.malonetalk.interceptor.AgentAuthInterceptor; import io.github.malonetalk.interceptor.AuthInterceptor; import lombok.AllArgsConstructor; import org.springframework.context.annotation.Configuration; @@ -29,11 +30,13 @@ public class WebMvcConfig implements WebMvcConfigurer { private final AuthInterceptor authInterceptor; + private final AgentAuthInterceptor agentAuthInterceptor; @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(authInterceptor) .addPathPatterns("/api/**") .excludePathPatterns("/api/auth/login", "/error"); + registry.addInterceptor(agentAuthInterceptor).addPathPatterns("/agent/**"); } } diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/controller/UserPatController.java b/data-agent-backend/src/main/java/io/github/malonetalk/controller/UserPatController.java new file mode 100644 index 00000000..4d570f4a --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/controller/UserPatController.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.controller; + +import io.github.malonetalk.annotation.RequirePermission; +import io.github.malonetalk.enums.PermissionEnum; +import io.github.malonetalk.model.bo.UserPatCreateResultBo; +import io.github.malonetalk.model.converter.UserPatConverter; +import io.github.malonetalk.model.dto.UserPatCreateDto; +import io.github.malonetalk.model.holder.UserContextHolder; +import io.github.malonetalk.model.vo.BooleanVo; +import io.github.malonetalk.model.vo.ListVo; +import io.github.malonetalk.model.vo.UserPatCreatedVo; +import io.github.malonetalk.model.vo.UserPatVo; +import io.github.malonetalk.service.UserPatService; +import jakarta.validation.Valid; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@AllArgsConstructor +@RequestMapping("/api/auth/pats") +public class UserPatController { + + private final UserPatService userPatService; + private final UserPatConverter converter; + private final UserContextHolder userContextHolder; + + @PostMapping + @RequirePermission(PermissionEnum.ACCESS_PAT_MANAGE) + public UserPatCreatedVo create(@Valid @RequestBody UserPatCreateDto request) { + UserPatCreateResultBo result = userPatService.create(currentUserId(), request); + return new UserPatCreatedVo(converter.toVo(result.pat()), result.token()); + } + + @GetMapping + @RequirePermission(PermissionEnum.ACCESS_PAT_MANAGE) + public ListVo list() { + return new ListVo<>( + userPatService.list(currentUserId()).stream().map(converter::toVo).toList()); + } + + @DeleteMapping("/{id}") + @RequirePermission(PermissionEnum.ACCESS_PAT_MANAGE) + public BooleanVo revoke(@PathVariable Long id) { + userPatService.revoke(currentUserId(), id); + return BooleanVo.TRUE; + } + + private Integer currentUserId() { + return userContextHolder.checkAndGet().userId(); + } +} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/enums/PermissionEnum.java b/data-agent-backend/src/main/java/io/github/malonetalk/enums/PermissionEnum.java index 7c5df9f8..b36ac762 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/enums/PermissionEnum.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/enums/PermissionEnum.java @@ -75,7 +75,8 @@ public enum PermissionEnum { SYS_ROLE_GRANT("sys:role:grant", "角色:授权", "角色", true), SYS_MCP_READ("sys:mcp:read", "MCP 配置:查看", "MCP 配置"), SYS_MCP_UPDATE("sys:mcp:update", "MCP 配置:修改", "MCP 配置"), - SYS_MCP_SET_STATUS("sys:mcp:set-status", "MCP 配置:启停", "MCP 配置"); + SYS_MCP_SET_STATUS("sys:mcp:set-status", "MCP 配置:启停", "MCP 配置"), + ACCESS_PAT_MANAGE("access:pat:manage", "访问令牌:管理", "访问令牌"); private final String code; private final String name; diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/interceptor/AgentAuthInterceptor.java b/data-agent-backend/src/main/java/io/github/malonetalk/interceptor/AgentAuthInterceptor.java new file mode 100644 index 00000000..7c6ae23a --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/interceptor/AgentAuthInterceptor.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.interceptor; + +import io.github.malonetalk.exception.BusinessException; +import io.github.malonetalk.exception.ErrorCode; +import io.github.malonetalk.model.bo.UserContextBo; +import io.github.malonetalk.model.bo.UserPatBo; +import io.github.malonetalk.model.holder.UserContextHolder; +import io.github.malonetalk.service.PermissionService; +import io.github.malonetalk.service.UserPatService; +import io.github.malonetalk.utils.BearerTokenUtils; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.AsyncHandlerInterceptor; + +/** `/agent/**` 的 PAT 鉴权:解析 Bearer Token,加载用户并检查启用状态。 */ +@Slf4j +@Component +@AllArgsConstructor +public class AgentAuthInterceptor implements AsyncHandlerInterceptor { + + public static final String AUTHENTICATED_PAT_ATTRIBUTE = "authenticatedPat"; + + private final UserPatService userPatService; + private final PermissionService permissions; + private final UserContextHolder userContextHolder; + + @Override + public boolean preHandle( + HttpServletRequest request, HttpServletResponse response, Object handler) { + var authenticated = userPatService.authenticate(BearerTokenUtils.extract(request)); + if (authenticated.isEmpty()) { + log.warn("Agent request rejected: invalid PAT, path={}", request.getRequestURI()); + throw BusinessException.of(ErrorCode.UNAUTHORIZED); + } + UserPatBo pat = authenticated.get(); + UserContextBo context = permissions.user(pat.userId()); + userContextHolder.set(context); + request.setAttribute(AUTHENTICATED_PAT_ATTRIBUTE, pat); + return true; + } + + @Override + public void afterConcurrentHandlingStarted( + HttpServletRequest request, HttpServletResponse response, Object handler) { + userContextHolder.clear(); + } + + @Override + public void afterCompletion( + HttpServletRequest request, + HttpServletResponse response, + Object handler, + Exception ex) { + userContextHolder.clear(); + } +} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/interceptor/AuthInterceptor.java b/data-agent-backend/src/main/java/io/github/malonetalk/interceptor/AuthInterceptor.java index 1b33fd78..2c812f6f 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/interceptor/AuthInterceptor.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/interceptor/AuthInterceptor.java @@ -24,6 +24,7 @@ import io.github.malonetalk.model.bo.UserContextBo; import io.github.malonetalk.model.holder.UserContextHolder; import io.github.malonetalk.service.PermissionService; +import io.github.malonetalk.utils.BearerTokenUtils; import io.github.malonetalk.utils.JwtUtil; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -49,7 +50,8 @@ public class AuthInterceptor implements AsyncHandlerInterceptor { @Override public boolean preHandle( HttpServletRequest request, HttpServletResponse response, Object handler) { - UserContextBo context = permissions.user(jwtUtil.parseUserId(extractBearer(request))); + UserContextBo context = + permissions.user(jwtUtil.parseUserId(BearerTokenUtils.extract(request))); userContextHolder.set(context); try { @@ -87,18 +89,4 @@ public void afterCompletion( Exception ex) { userContextHolder.clear(); } - - private String extractBearer(HttpServletRequest request) { - String header = request.getHeader("Authorization"); - if (header == null || header.isBlank()) { - return null; - } - String trimmed = header.trim(); - String prefix = "Bearer "; - if (trimmed.length() > prefix.length() - && trimmed.regionMatches(true, 0, prefix, 0, prefix.length())) { - return trimmed.substring(prefix.length()).trim(); - } - return null; - } } diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/mapper/UserPatMapper.java b/data-agent-backend/src/main/java/io/github/malonetalk/mapper/UserPatMapper.java new file mode 100644 index 00000000..e0cae3cd --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/mapper/UserPatMapper.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.mapper; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import io.github.malonetalk.model.po.UserPatPo; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface UserPatMapper extends AuditableMapper { + + default UserPatPo selectByTokenHash(String tokenHash) { + // NULL 会让 MP 丢弃该条件,必须提前拒绝,避免退化为全表查询。 + if (tokenHash == null || tokenHash.isBlank()) { + return null; + } + return selectOne( + Wrappers.lambdaQuery() + .select( + UserPatPo::getId, + UserPatPo::getUserId, + UserPatPo::getName, + UserPatPo::getTokenPrefix, + UserPatPo::getTokenHash, + UserPatPo::getExpiresAt, + UserPatPo::getLastUsedAt, + UserPatPo::getRevokedAt, + UserPatPo::getCreateTime) + .eq(UserPatPo::getTokenHash, tokenHash)); + } +} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/model/bo/AgentToolDefinitionBo.java b/data-agent-backend/src/main/java/io/github/malonetalk/model/bo/AgentToolDefinitionBo.java new file mode 100644 index 00000000..2ecf02f5 --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/model/bo/AgentToolDefinitionBo.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.model.bo; + +import java.util.Map; + +public record AgentToolDefinitionBo( + String name, String description, Map parameters) {} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/model/bo/UserPatBo.java b/data-agent-backend/src/main/java/io/github/malonetalk/model/bo/UserPatBo.java new file mode 100644 index 00000000..d49eda0b --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/model/bo/UserPatBo.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.model.bo; + +import java.time.LocalDateTime; + +public record UserPatBo( + Long id, + Integer userId, + String name, + String tokenPrefix, + LocalDateTime expiresAt, + LocalDateTime lastUsedAt, + LocalDateTime revokedAt, + LocalDateTime createTime) {} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/MarkAgentTool.java b/data-agent-backend/src/main/java/io/github/malonetalk/model/bo/UserPatCreateResultBo.java similarity index 81% rename from data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/MarkAgentTool.java rename to data-agent-backend/src/main/java/io/github/malonetalk/model/bo/UserPatCreateResultBo.java index ddf185ad..6eb13c5f 100644 --- a/data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/MarkAgentTool.java +++ b/data-agent-backend/src/main/java/io/github/malonetalk/model/bo/UserPatCreateResultBo.java @@ -15,6 +15,7 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.model.bo; -public interface MarkAgentTool {} +/** 创建结果:token 为明文,只能返回一次。 */ +public record UserPatCreateResultBo(UserPatBo pat, String token) {} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/model/converter/UserPatConverter.java b/data-agent-backend/src/main/java/io/github/malonetalk/model/converter/UserPatConverter.java new file mode 100644 index 00000000..242b6f83 --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/model/converter/UserPatConverter.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.model.converter; + +import io.github.malonetalk.model.bo.UserPatBo; +import io.github.malonetalk.model.po.UserPatPo; +import io.github.malonetalk.model.vo.UserPatVo; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface UserPatConverter { + + UserPatBo toBo(UserPatPo po); + + UserPatVo toVo(UserPatBo bo); +} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/model/dto/UserPatCreateDto.java b/data-agent-backend/src/main/java/io/github/malonetalk/model/dto/UserPatCreateDto.java new file mode 100644 index 00000000..b0c3964e --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/model/dto/UserPatCreateDto.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.model.dto; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; +import java.time.LocalDateTime; + +public record UserPatCreateDto( + @NotBlank(message = "名称不能为空") @Size(max = 64, message = "名称不能超过 64 个字符") String name, + LocalDateTime expiresAt) {} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/model/po/UserPatPo.java b/data-agent-backend/src/main/java/io/github/malonetalk/model/po/UserPatPo.java new file mode 100644 index 00000000..b128a7ec --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/model/po/UserPatPo.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.model.po; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.time.LocalDateTime; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** 用户个人访问令牌(PAT)。数据库只保存哈希,明文只在创建时返回一次。 */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("user_pat") +public class UserPatPo extends BasePo { + + @TableId(type = IdType.AUTO) + private Long id; + + private Integer userId; + private String name; + private String tokenPrefix; + private String tokenHash; + private LocalDateTime expiresAt; + private LocalDateTime lastUsedAt; + private LocalDateTime revokedAt; +} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/model/vo/AgentToolVo.java b/data-agent-backend/src/main/java/io/github/malonetalk/model/vo/AgentToolVo.java new file mode 100644 index 00000000..bc61ebd5 --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/model/vo/AgentToolVo.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.model.vo; + +import java.util.Map; + +public record AgentToolVo(String name, String description, Map parameters) + implements BaseVo {} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/model/vo/ToolResultVo.java b/data-agent-backend/src/main/java/io/github/malonetalk/model/vo/ToolResultVo.java new file mode 100644 index 00000000..e164f41a --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/model/vo/ToolResultVo.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.model.vo; + +import java.util.Map; + +public record ToolResultVo(String text, Map metadata, String traceId) + implements BaseVo {} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/model/vo/UserPatCreatedVo.java b/data-agent-backend/src/main/java/io/github/malonetalk/model/vo/UserPatCreatedVo.java new file mode 100644 index 00000000..4d93f8c8 --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/model/vo/UserPatCreatedVo.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.model.vo; + +/** 创建成功响应:token 为明文,只能获取一次。 */ +public record UserPatCreatedVo(UserPatVo pat, String token) implements BaseVo {} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/model/vo/UserPatVo.java b/data-agent-backend/src/main/java/io/github/malonetalk/model/vo/UserPatVo.java new file mode 100644 index 00000000..bd37ccb0 --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/model/vo/UserPatVo.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.model.vo; + +import java.time.LocalDateTime; + +public record UserPatVo( + Long id, + String name, + String tokenPrefix, + LocalDateTime expiresAt, + LocalDateTime lastUsedAt, + LocalDateTime revokedAt, + LocalDateTime createTime) + implements BaseVo {} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/service/UserPatService.java b/data-agent-backend/src/main/java/io/github/malonetalk/service/UserPatService.java new file mode 100644 index 00000000..a3b7d003 --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/service/UserPatService.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.service; + +import io.github.malonetalk.model.bo.UserPatBo; +import io.github.malonetalk.model.bo.UserPatCreateResultBo; +import io.github.malonetalk.model.dto.UserPatCreateDto; +import java.util.List; +import java.util.Optional; + +public interface UserPatService { + + UserPatCreateResultBo create(Integer userId, UserPatCreateDto request); + + List list(Integer userId); + + void revoke(Integer userId, Long id); + + Optional authenticate(String rawToken); +} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/service/UserPatServiceImpl.java b/data-agent-backend/src/main/java/io/github/malonetalk/service/UserPatServiceImpl.java new file mode 100644 index 00000000..596be18a --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/service/UserPatServiceImpl.java @@ -0,0 +1,235 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.service; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import io.github.malonetalk.exception.BusinessException; +import io.github.malonetalk.exception.ErrorCode; +import io.github.malonetalk.mapper.UserPatMapper; +import io.github.malonetalk.model.bo.UserPatBo; +import io.github.malonetalk.model.bo.UserPatCreateResultBo; +import io.github.malonetalk.model.converter.UserPatConverter; +import io.github.malonetalk.model.dto.UserPatCreateDto; +import io.github.malonetalk.model.po.UserPatPo; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.time.LocalDateTime; +import java.util.Base64; +import java.util.HexFormat; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Service +@RequiredArgsConstructor +public class UserPatServiceImpl implements UserPatService { + + static final int MAX_ACTIVE_PATS = 10; + private static final int DEFAULT_EXPIRY_DAYS = 90; + private static final int MAX_EXPIRY_DAYS = 365; + private static final int MIN_EXPIRY_DAYS = 1; + private static final int TOKEN_PREFIX_LENGTH = 12; + private static final int TOKEN_BYTES = 32; + private static final int LAST_USED_UPDATE_MINUTES = 5; + private static final String TOKEN_PREFIX = "pat_"; + private static final SecureRandom RANDOM = new SecureRandom(); + + private final UserPatMapper userPatMapper; + private final UserPatConverter converter; + + @Override + @Transactional + public UserPatCreateResultBo create(Integer userId, UserPatCreateDto request) { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime expiresAt = resolveExpiresAt(request.expiresAt(), now); + if (activeCount(userId, now) >= MAX_ACTIVE_PATS) { + throw BusinessException.of( + ErrorCode.DATA_CONFLICT, + "Active personal access tokens cannot exceed " + MAX_ACTIVE_PATS + "."); + } + + String token = generateToken(); + UserPatPo pat = new UserPatPo(); + pat.setUserId(userId); + pat.setName(requireName(request.name())); + pat.setTokenPrefix(tokenPrefix(token)); + pat.setTokenHash(hash(token)); + pat.setExpiresAt(expiresAt); + if (userPatMapper.insert(pat) == 0) { + throw BusinessException.of(ErrorCode.OPERATION_FAILED, "Failed to create the token."); + } + log.info( + "PAT created: userId={}, patId={}, name={}, expiresAt={}", + userId, + pat.getId(), + pat.getName(), + expiresAt); + return new UserPatCreateResultBo(converter.toBo(pat), token); + } + + @Override + @Transactional(readOnly = true) + public List list(Integer userId) { + return userPatMapper + .selectList( + Wrappers.lambdaQuery() + .select( + UserPatPo::getId, + UserPatPo::getName, + UserPatPo::getTokenPrefix, + UserPatPo::getExpiresAt, + UserPatPo::getLastUsedAt, + UserPatPo::getRevokedAt, + UserPatPo::getCreateTime) + .eq(UserPatPo::getUserId, userId) + .orderByDesc(UserPatPo::getCreateTime)) + .stream() + .map(converter::toBo) + .toList(); + } + + @Override + @Transactional + public void revoke(Integer userId, Long id) { + UserPatPo existing = + userPatMapper.selectOne( + Wrappers.lambdaQuery() + .select( + UserPatPo::getId, + UserPatPo::getUserId, + UserPatPo::getRevokedAt) + .eq(UserPatPo::getId, id)); + if (existing == null || !Objects.equals(existing.getUserId(), userId)) { + throw BusinessException.of(ErrorCode.RESOURCE_NOT_FOUND, "Token not found."); + } + if (existing.getRevokedAt() != null) { + return; + } + + UserPatPo update = new UserPatPo(); + update.setId(id); + update.setRevokedAt(LocalDateTime.now()); + if (userPatMapper.updateById(update) == 0) { + throw BusinessException.of(ErrorCode.OPERATION_FAILED, "Failed to revoke the token."); + } + log.info("PAT revoked: userId={}, patId={}", userId, id); + } + + @Override + @Transactional + public Optional authenticate(String rawToken) { + if (rawToken == null || rawToken.isBlank()) { + return Optional.empty(); + } + String token = rawToken.trim(); + if (!token.startsWith(TOKEN_PREFIX)) { + return Optional.empty(); + } + + String presentedHash = hash(token); + UserPatPo pat = userPatMapper.selectByTokenHash(presentedHash); + if (pat == null || !constantTimeEquals(presentedHash, pat.getTokenHash())) { + return Optional.empty(); + } + + LocalDateTime now = LocalDateTime.now(); + if (pat.getRevokedAt() != null) { + return Optional.empty(); + } + if (pat.getExpiresAt() == null || !pat.getExpiresAt().isAfter(now)) { + return Optional.empty(); + } + + updateLastUsedAt(pat, now); + return Optional.of(converter.toBo(pat)); + } + + private void updateLastUsedAt(UserPatPo pat, LocalDateTime now) { + if (pat.getLastUsedAt() != null + && pat.getLastUsedAt().isAfter(now.minusMinutes(LAST_USED_UPDATE_MINUTES))) { + return; + } + UserPatPo update = new UserPatPo(); + update.setId(pat.getId()); + update.setLastUsedAt(now); + userPatMapper.updateById(update); + } + + /** 常量时间比较,避免普通字符串比较按首个差异字节提前返回导致时序侧信道。 */ + private static boolean constantTimeEquals(String left, String right) { + return MessageDigest.isEqual( + left.getBytes(StandardCharsets.UTF_8), right.getBytes(StandardCharsets.UTF_8)); + } + + private Long activeCount(Integer userId, LocalDateTime now) { + return userPatMapper.selectCount( + Wrappers.lambdaQuery() + .eq(UserPatPo::getUserId, userId) + .isNull(UserPatPo::getRevokedAt) + .gt(UserPatPo::getExpiresAt, now)); + } + + private static String requireName(String name) { + return Optional.ofNullable(name) + .map(String::trim) + .filter(value -> !value.isEmpty()) + .orElseThrow( + () -> BusinessException.of(ErrorCode.BAD_REQUEST, "Name is required.")); + } + + private static LocalDateTime resolveExpiresAt(LocalDateTime requested, LocalDateTime now) { + LocalDateTime expiresAt = + Optional.ofNullable(requested).orElse(now.plusDays(DEFAULT_EXPIRY_DAYS)); + if (expiresAt.isBefore(now.plusDays(MIN_EXPIRY_DAYS))) { + throw BusinessException.of( + ErrorCode.BAD_REQUEST, "Expiration must be at least 1 day later."); + } + if (expiresAt.isAfter(now.plusDays(MAX_EXPIRY_DAYS))) { + throw BusinessException.of( + ErrorCode.BAD_REQUEST, + "Expiration cannot exceed " + MAX_EXPIRY_DAYS + " days."); + } + return expiresAt; + } + + private static String generateToken() { + byte[] bytes = new byte[TOKEN_BYTES]; + RANDOM.nextBytes(bytes); + return TOKEN_PREFIX + Base64.getUrlEncoder().withoutPadding().encodeToString(bytes); + } + + private static String tokenPrefix(String token) { + return token.substring(0, Math.min(TOKEN_PREFIX_LENGTH, token.length())); + } + + private static String hash(String token) { + try { + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + return HexFormat.of().formatHex(digest.digest(token.getBytes(StandardCharsets.UTF_8))); + } catch (NoSuchAlgorithmException e) { + throw new IllegalStateException("SHA-256 is not available.", e); + } + } +} diff --git a/data-agent-backend/src/main/java/io/github/malonetalk/utils/BearerTokenUtils.java b/data-agent-backend/src/main/java/io/github/malonetalk/utils/BearerTokenUtils.java new file mode 100644 index 00000000..5681034a --- /dev/null +++ b/data-agent-backend/src/main/java/io/github/malonetalk/utils/BearerTokenUtils.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.utils; + +import jakarta.servlet.http.HttpServletRequest; + +/** 从 Authorization 请求头读取 Bearer Token。 */ +public final class BearerTokenUtils { + + private static final String PREFIX = "Bearer "; + + private BearerTokenUtils() {} + + public static String extract(HttpServletRequest request) { + String header = request.getHeader("Authorization"); + if (header == null || header.isBlank()) { + return null; + } + String trimmed = header.trim(); + if (trimmed.length() > PREFIX.length() + && trimmed.regionMatches(true, 0, PREFIX, 0, PREFIX.length())) { + return trimmed.substring(PREFIX.length()).trim(); + } + return null; + } +} diff --git a/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/AgentToolInvokerTest.java b/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/AgentToolInvokerTest.java new file mode 100644 index 00000000..e66c6c44 --- /dev/null +++ b/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/AgentToolInvokerTest.java @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * limitations under the License. + */ +package io.github.malonetalk.agent.tools; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.agentscope.core.tool.Tool; +import io.agentscope.core.tool.ToolParam; +import io.github.malonetalk.agent.ToolCallContext; +import io.github.malonetalk.exception.BusinessException; +import io.github.malonetalk.exception.ErrorCode; +import io.github.malonetalk.model.bo.AgentToolDefinitionBo; +import io.github.malonetalk.model.bo.ToolResultBo; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Test; + +class AgentToolInvokerTest { + + private final AgentToolInvoker invoker = + new AgentToolInvoker( + List.of(new ExposedTool(), new AgentOnlyTool()), new ObjectMapper()); + + AgentToolInvokerTest() { + invoker.init(); + } + + @Test + void listsAllRestToolsFromOneBean() { + List tools = invoker.list(); + + assertEquals(2, tools.size()); + AgentToolDefinitionBo echo = + tools.stream().filter(tool -> "echo".equals(tool.name())).findFirst().orElseThrow(); + assertEquals("Echo a message.", echo.description()); + Map properties = (Map) echo.parameters().get("properties"); + assertTrue(properties.containsKey("message")); + assertTrue(tools.stream().anyMatch(tool -> "ping".equals(tool.name()))); + } + + @Test + void invokesToolAndInjectsContext() { + ToolResultBo result = + invoker.invoke( + "echo", + Map.of("message", "hello"), + ToolCallContext.builder().userId(7).build()); + + assertEquals("hello:7", result.text()); + } + + @Test + void rejectsMissingRequiredParameter() { + BusinessException exception = + assertThrows( + BusinessException.class, + () -> + invoker.invoke( + "echo", + Map.of(), + ToolCallContext.builder().userId(7).build())); + + assertEquals(ErrorCode.BAD_REQUEST, exception.getErrorCode()); + } + + @Test + void rejectsUnknownTool() { + BusinessException exception = + assertThrows( + BusinessException.class, + () -> + invoker.invoke( + "missing", + Map.of(), + ToolCallContext.builder().userId(7).build())); + + assertEquals(ErrorCode.RESOURCE_NOT_FOUND, exception.getErrorCode()); + } + + private static class ExposedTool implements DataAgentTool { + + @RestTool + @Tool(name = "echo", description = "Echo a message.") + public ToolResultBo echo( + @ToolParam(name = "message", description = "Message") String message, + ToolCallContext context) { + return new ToolResultBo(message + ":" + context.userId(), Map.of()); + } + + @RestTool + @Tool(name = "ping", description = "Ping.") + public ToolResultBo ping(ToolCallContext context) { + return new ToolResultBo("pong:" + context.userId(), Map.of()); + } + } + + private static class AgentOnlyTool implements DataAgentTool { + + @Tool(name = "internal", description = "Internal tool.") + public ToolResultBo internal() { + return ToolResultBo.of("internal"); + } + } +} diff --git a/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/DateInfoToolTest.java b/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/impls/DateInfoToolTest.java similarity index 99% rename from data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/DateInfoToolTest.java rename to data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/impls/DateInfoToolTest.java index 3c8ee593..4972d507 100644 --- a/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/DateInfoToolTest.java +++ b/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/impls/DateInfoToolTest.java @@ -15,7 +15,7 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/ToolDatasourceResolverTest.java b/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/impls/ToolDatasourceResolverTest.java similarity index 97% rename from data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/ToolDatasourceResolverTest.java rename to data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/impls/ToolDatasourceResolverTest.java index cdbe632d..e6617261 100644 --- a/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/ToolDatasourceResolverTest.java +++ b/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/impls/ToolDatasourceResolverTest.java @@ -15,7 +15,7 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertSame; @@ -26,6 +26,7 @@ import static org.mockito.Mockito.when; import io.github.malonetalk.agent.ToolCallContext; +import io.github.malonetalk.agent.tools.ToolDatasourceResolver; import io.github.malonetalk.enums.Status; import io.github.malonetalk.exception.BusinessException; import io.github.malonetalk.exception.ErrorCode; diff --git a/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/ToolResultBoConverterTest.java b/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/impls/ToolResultBoConverterTest.java similarity index 94% rename from data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/ToolResultBoConverterTest.java rename to data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/impls/ToolResultBoConverterTest.java index f5152f6c..1e0fbd88 100644 --- a/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/ToolResultBoConverterTest.java +++ b/data-agent-backend/src/test/java/io/github/malonetalk/agent/tools/impls/ToolResultBoConverterTest.java @@ -15,7 +15,7 @@ * along with this program. If not, see . * limitations under the License. */ -package io.github.malonetalk.agent.tools; +package io.github.malonetalk.agent.tools.impls; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -23,6 +23,8 @@ import io.agentscope.core.message.TextBlock; import io.agentscope.core.message.ToolResultBlock; import io.agentscope.core.tool.ToolSuspendException; +import io.github.malonetalk.agent.tools.ToolExceptionMapper; +import io.github.malonetalk.agent.tools.ToolResultBoConverter; import io.github.malonetalk.exception.BusinessException; import io.github.malonetalk.exception.ErrorCode; import io.github.malonetalk.exception.ExceptionResponseMapper; diff --git a/data-agent-backend/src/test/java/io/github/malonetalk/interceptor/PermissionIntegrationTest.java b/data-agent-backend/src/test/java/io/github/malonetalk/interceptor/PermissionIntegrationTest.java index bb560b9c..6e63222c 100644 --- a/data-agent-backend/src/test/java/io/github/malonetalk/interceptor/PermissionIntegrationTest.java +++ b/data-agent-backend/src/test/java/io/github/malonetalk/interceptor/PermissionIntegrationTest.java @@ -232,6 +232,8 @@ void webConfigurationEnforcesPermissionsAndDefaultDenial() throws Exception { Mappers.getMapper(UserConverter.class))); factory.registerSingleton("jwtUtil", jwt); factory.registerSingleton("userContextHolder", holder); + factory.registerSingleton( + "agentAuthInterceptor", mock(AgentAuthInterceptor.class)); }); context.refresh(); var mvc = diff --git a/data-agent-cli/.prettierignore b/data-agent-cli/.prettierignore new file mode 100644 index 00000000..036e0738 --- /dev/null +++ b/data-agent-cli/.prettierignore @@ -0,0 +1,6 @@ +dist +node_modules +coverage +package-lock.json +*.log +*.tsbuildinfo diff --git a/data-agent-cli/.prettierrc b/data-agent-cli/.prettierrc new file mode 100644 index 00000000..4d3039f2 --- /dev/null +++ b/data-agent-cli/.prettierrc @@ -0,0 +1,11 @@ +{ + "semi": true, + "trailingComma": "all", + "singleQuote": true, + "printWidth": 100, + "tabWidth": 2, + "useTabs": false, + "bracketSpacing": true, + "arrowParens": "avoid", + "endOfLine": "lf" +} diff --git a/data-agent-cli/LICENSE b/data-agent-cli/LICENSE new file mode 100644 index 00000000..0ad25db4 --- /dev/null +++ b/data-agent-cli/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/data-agent-cli/README.md b/data-agent-cli/README.md new file mode 100644 index 00000000..e0ecfabd --- /dev/null +++ b/data-agent-cli/README.md @@ -0,0 +1,143 @@ +# data-agent-cli + +通过 PAT 调用 DataAgent 只读工具的命令行客户端。 + +需要 Node.js 20 或更高版本。 + +## 安装 + +```bash +npm install -g @malone-talk/data-agent-cli +``` + +## 创建 PAT + +在浏览器中打开 DataAgent,进入 **API 访问令牌** 页面(`/settings/tokens`),创建令牌并复制。Token 只会显示一次。 + +## 登录 + +```bash +data-agent-cli auth login +``` + +也可以直接传入 Token: + +```bash +data-agent-cli auth login --token pat_xxx +``` + +`auth login` 会调用 `GET /agent/health` 校验 Token,成功后把 Token 和 Base URL 保存到本地配置。 + +```bash +data-agent-cli auth status +data-agent-cli auth logout +``` + +默认 Base URL 是 `http://localhost:8080`。 + +## 工具 + +```bash +data-agent-cli tools list +data-agent-cli tools describe get_tables +``` + +使用 JSON 输入调用工具: + +```bash +data-agent-cli tools call get_domains --input '{"datasource_id":1}' + +data-agent-cli tools call get_tables \ + --input '{"datasource_id":1,"domains":["sales"]}' \ + --json +``` + +`--input` 也支持文件或 stdin: + +```bash +data-agent-cli tools call execute_sql --input @query.json +printf '{"datasource_id":1}' | data-agent-cli tools call get_domains --input - +``` + +`execute_sql` 只支持 SELECT。查询结果最多返回 200 行,需要更多数据时使用 `LIMIT/OFFSET` 分页。 + +## Agent 指南 + +输出面向外部 Agent 的 Markdown 使用指南: + +```bash +data-agent-cli skill +``` + +指南包含认证检查、工具发现、推荐问数流程、session 处理以及输出与错误约定。 + +## Session 与 Trace + +通过 `--session-id` 让多次调用属于同一个业务会话: + +```bash +data-agent-cli tools call get_tables \ + --session-id run-123 \ + --input '{"datasource_id":1,"domains":["sales"]}' +``` + +也可以设置 `DATAAGENT_SESSION_ID`。 + +CLI 会自动发送 W3C `traceparent`。同一 session 在 30 分钟空闲窗口内复用同一个 traceId。 + +## 配置 + +配置路径: + +```text +Linux/macOS: ${XDG_CONFIG_HOME:-~/.config}/data-agent-cli/config.json +Windows: %APPDATA%\data-agent-cli\config.json +``` + +示例: + +```json +{ + "baseUrl": "http://localhost:8080", + "token": "pat_xxx", + "timeoutSeconds": 60 +} +``` + +环境变量: + +```text +DATAAGENT_TOKEN +DATAAGENT_BASE_URL +DATAAGENT_SESSION_ID +TRACEPARENT +``` + +Token 优先级:`--token` > 配置文件 > `DATAAGENT_TOKEN`。 + +## 输出 + +- 交互式终端:输出人类可读文本或表格 +- `--json` 或 stdout 非 TTY:输出 JSON +- `--json` 模式下错误也以 JSON 输出到 stdout +- 日志、进度、警告和 `--verbose` 详情输出到 stderr + +退出码: + +```text +0 成功 +2 参数、输入或配置错误 +3 认证或授权失败 +4 网络错误或超时 +5 服务端错误或工具执行失败 +``` + +## 开发 + +```bash +npm ci +npm run lint:check +npm run format:check +npm run build +npm test +``` diff --git a/data-agent-cli/eslint.config.js b/data-agent-cli/eslint.config.js new file mode 100644 index 00000000..6d7f393f --- /dev/null +++ b/data-agent-cli/eslint.config.js @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import js from '@eslint/js'; +import tseslint from 'typescript-eslint'; +import eslintConfigPrettier from 'eslint-config-prettier'; +import globals from 'globals'; + +const LICENSE_LINES = [ + 'Copyright (C) 2026 github.com/MaloneTalk', + '', + 'This program is free software: you can redistribute it and/or modify', + 'it under the terms of the GNU Affero General Public License as', + 'published by the Free Software Foundation, either version 3 of the', + 'License, or any later version.', + '', + 'This program is distributed in the hope that it will be useful', + 'but WITHOUT ANY WARRANTY; without even the implied warranty of', + 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the', + 'GNU Affero General Public License for more details.', + '', + 'You should have received a copy of the GNU Affero General Public License', + 'along with this program. If not, see .', +]; + +const LICENSE_HEADER = ['/*', ...LICENSE_LINES.map(line => ` * ${line}`), ' */'].join('\n'); + +function hasValidLicense(text) { + const content = text.replace(/\s+/g, ' ').trim(); + const requiredPatterns = [ + /Copyright\s*\(C\)\s*2026\s*github\.com\/MaloneTalk/i, + /GNU\s+Affero\s+General\s+Public\s+License/i, + /version\s+3/i, + /Free\s+Software\s+Foundation/i, + ]; + return requiredPatterns.every(pattern => pattern.test(content)); +} + +function licenseHeaderOffset(sourceText) { + return sourceText.startsWith('#!') ? sourceText.indexOf('\n') + 1 : 0; +} + +const licenseHeaderPlugin = { + rules: { + 'license-header': { + meta: { + type: 'layout', + fixable: 'code', + schema: [], + }, + create(context) { + return { + Program() { + const sourceCode = context.sourceCode; + const sourceText = sourceCode.text; + const offset = licenseHeaderOffset(sourceText); + const firstComment = sourceCode + .getAllComments() + .find(comment => comment.range[0] === offset); + + if (firstComment && hasValidLicense(firstComment.value)) { + return; + } + + context.report({ + loc: { line: 1, column: 0 }, + message: '文件缺少许可证声明', + fix(fixer) { + return fixer.insertTextBeforeRange([offset, offset], LICENSE_HEADER + '\n\n'); + }, + }); + }, + }; + }, + }, + }, +}; + +export default tseslint.config( + { + ignores: ['node_modules/**', 'dist/**', 'coverage/**', '*.tsbuildinfo'], + }, + js.configs.recommended, + ...tseslint.configs.recommended, + eslintConfigPrettier, + { + plugins: { 'license-header-plugin': licenseHeaderPlugin }, + rules: { + 'license-header-plugin/license-header': 'error', + }, + }, + { + files: ['**/*.js', '**/*.ts'], + languageOptions: { + parser: tseslint.parser, + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + }, + globals: globals.node, + }, + rules: { + '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }], + 'prefer-const': 'error', + 'no-var': 'error', + 'object-shorthand': 'error', + 'quote-props': ['error', 'as-needed'], + 'no-console': 'off', + 'no-debugger': 'error', + }, + }, +); diff --git a/data-agent-cli/package-lock.json b/data-agent-cli/package-lock.json new file mode 100644 index 00000000..0cde3933 --- /dev/null +++ b/data-agent-cli/package-lock.json @@ -0,0 +1,2928 @@ +{ + "name": "@malone-talk/data-agent-cli", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@malone-talk/data-agent-cli", + "version": "1.0.0", + "license": "AGPL-3.0-or-later", + "dependencies": { + "commander": "^13.1.0" + }, + "bin": { + "data-agent-cli": "dist/index.js" + }, + "devDependencies": { + "@eslint/js": "^10.0.1", + "@types/node": "^20.17.30", + "eslint": "^10.0.0", + "eslint-config-prettier": "^10.1.1", + "globals": "^16.0.0", + "prettier": "^3.5.3", + "typescript": "~5.6.2", + "typescript-eslint": "^8.18.1", + "vitest": "^3.0.8" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@cacheable/memory": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz", + "integrity": "sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cacheable/utils": "^2.5.0", + "@keyv/bigmap": "^1.3.1", + "hookified": "^1.15.1", + "keyv": "^5.6.0" + } + }, + "node_modules/@cacheable/utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@cacheable/utils/-/utils-2.5.0.tgz", + "integrity": "sha512-buipgOVDkkPXNR5+xBpDw7Zk2n1EvU7qBJCNUcL7rhQ//kfpOXPAvQ511Os0vpLYJ1pZnvudNytkQt2hst3wqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hashery": "^1.5.1", + "keyv": "^5.6.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz", + "integrity": "sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.3", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.3.tgz", + "integrity": "sha512-R76UKbvsqI68DJJVTVyqFKqU98CN4+B+acxNfEA2IFarSzP0SjtKf/3+fFiXzTyv5Fj3PxLkGHe2wnVWWMxobQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.23.5", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.5.tgz", + "integrity": "sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^3.0.5", + "debug": "^4.3.1", + "minimatch": "^10.2.4" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/config-helpers": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.7.0.tgz", + "integrity": "sha512-DObd/KKUsU+FaFv4PLxSRenpXfQWmPXXP3pPZ6/K1PCrMu2vQpMDMuQe/BqYeoLcz8ro0bVDF1RxOJgfVEdhUw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.2.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/core": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.2.1.tgz", + "integrity": "sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/js": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-10.0.1.tgz", + "integrity": "sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "eslint": "^10.0.0" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/@eslint/object-schema": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-3.0.5.tgz", + "integrity": "sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.7.3.tgz", + "integrity": "sha512-IkO+/KEUvwbVpiURZg+P7zF74z5Jxe0UgJxVni+RtoHQ6IZieXaO02kmadomap/q+l6bc/jdPGGqTjhuZnuz1Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^1.2.1", + "levn": "^0.4.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@humanfs/core": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz", + "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/types": "^0.15.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.8.tgz", + "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.2", + "@humanfs/types": "^0.15.0", + "@humanwhocodes/retry": "^0.4.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/types": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@humanfs/types/-/types-0.15.0.tgz", + "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@keyv/bigmap": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@keyv/bigmap/-/bigmap-1.3.1.tgz", + "integrity": "sha512-WbzE9sdmQtKy8vrNPa9BRnwZh5UF4s1KTmSK0KUVLo3eff5BlQNNWDnFOouNpKfPKDnms9xynJjsMYjMaT/aFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "hashery": "^1.4.0", + "hookified": "^1.15.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "keyv": "^5.6.0" + } + }, + "node_modules/@keyv/serialize": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@keyv/serialize/-/serialize-1.1.1.tgz", + "integrity": "sha512-dXn3FZhPv0US+7dtJsIi2R+c7qWYiReoEh5zUntWCf4oSpMNib8FDhSoed6m3QyZdx5hK7iLFkYk3rNxwt8vTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.68.2.tgz", + "integrity": "sha512-ItKrNMkEL3hy85kLBXwB0+M6CWWVI8vr7RV+Eb7oDlQIMXLaiEhGfdaj5jAUadYn2v3nwzAhIRl/nLyjAqV9vQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.68.2.tgz", + "integrity": "sha512-dCkT8BMPLo6X6GCFVtuzrnr981PpJSeK4ZO/d/mZdJ/ao61Qa1Usd/OHIQ69MQgw4qQclR/X6uRRUONiWwD8cw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-x64": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-x64/-/rollup-android-x64-4.68.2.tgz", + "integrity": "sha512-p2jkKiscqQOGmyL6qu+KvJctvBc3SQTd+Xi2lQYn5QvFLEWz+QI8Z9iI+xcIjez6vKRsSnWP56Y3Ep7g3Stiug==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.68.2.tgz", + "integrity": "sha512-aVIfOteo5zoX8aL742H/S3QsyN6aokNYjdzrLnQBKxgRVoh4cibTErpi61RzSmrv2hBzDB1i751hwwdc8QK0vQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.68.2.tgz", + "integrity": "sha512-+Wuf4TFTHiE/WnjKgH1SkNf/9D5ddoed1UR0p3jxjNAGemdeeQRL+r1bJ1LlZyha0VKDBYLB2U/a9a9KlSw4Kw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.68.2.tgz", + "integrity": "sha512-feKK2dc13j/6D9mAp7XKhBM/VUqn0N/xRgP6rT7/mdRVVJUaeZ4lsJ9hN90aTi0k3OD+mkjlcN01vQ96Ac9VzQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.68.2.tgz", + "integrity": "sha512-s1oGXPGX1PNqdi9TLWD+RwtPEYf/BOTbCcq4anJBqNbzyjucti86ldYH37eKvsyTP7Bl5/Hf8XmbIxCz/iafTA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.68.2.tgz", + "integrity": "sha512-ksR3ZmzHrm6HOUP8UlDBy5hNTcG9cEIa3EyGnxn5BjorLRjBh4ucxhwjwwVEm0dqcIN4Egc/XjDUiPQwN1ic9A==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.68.2.tgz", + "integrity": "sha512-STZVVBM35wULVsQah0xKfCBQMPpHliOfjnRaUNT35jrbpfapUrD8ix6Yhl7tLHW0xQSWotXSSghjUi/DclwRSw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.68.2.tgz", + "integrity": "sha512-Fm/GPC2R0zlJYQIp9aY9L1lO2z+P+UrcvXG6fhubfo/BbMOLZlLXshnbECOTqr3pxfZFb6nNn0QgDETDtrX7TQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.68.2.tgz", + "integrity": "sha512-VoqlckWcwNF3WqsUkLZg91zYFgBvrC37Lc5e8AU+BKdCUFDMPoN0Rsin/LvF+rBVF527gWo5KT0oHkaAZaL1GA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.68.2.tgz", + "integrity": "sha512-Zr8X/SUf7Jjwxt99BqPDF/Wq+sz4oUBIP6HBaFQWwb8wO1nV6LBIpD6jB9cMybLho93Z+B8rrN0uXEL6oNOUJQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.68.2.tgz", + "integrity": "sha512-2EhrYEJNXIyhSZESwm/kCke1tiH7QAPOU3v3MsLM9J+Nfn2QCDe/pGROUAvYFK0BL2MEbzNgfrqrbnE5CFXkLw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.68.2.tgz", + "integrity": "sha512-IC0dYuEQknw0m2FYBNBKlbrgBJBH5OMRiaRfCc4CFSpYnmDnqTpNSv+TgX+loezGTdRjBNZuYZi3t+Oc5NxNYg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.68.2.tgz", + "integrity": "sha512-Zlzm6fGuDvtAqMEl071/g17vxq6u2Y2v/rON/gDY4NvzWLJ41BGAlwhF3QuAzwq05zIPo4LYzdqwhx3oisYCUw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.68.2.tgz", + "integrity": "sha512-KhEpYRtHZ3Kj4shavjXeH+K1bQlA6UbP6MJ45rMPF/11JlZb1SRNLeuWCdigUEoMMaFO4+LwwcS+ew1SoLJu/g==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.68.2.tgz", + "integrity": "sha512-LPn9qvPsM/Ofd6Ekq3im6nB8Tk1ruJhTd3x/2bJkTR8m/XTsfxA+EU0RJ23WJqgJg123kitHAqbEK7B4cL1uPg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.68.2.tgz", + "integrity": "sha512-Q1+E+pzSP+FiXuIZtxKR+pK7l2KQ9gsM+VaFPv1LR277kp7l61crG46WGLKLLay3Js5cvyU9Keqdzxa1EcFO+g==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.68.2.tgz", + "integrity": "sha512-3Btp4Lca/WzsmbaKu9Lh9d/XwyRDIegd/5khRBusHGw/Ll6SoF5Shn63OrjPdkLcpNi2PGDApXzNmxriRxGYjA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.68.2.tgz", + "integrity": "sha512-5SKVaUiVs18+DGBnpg0mORGxgq/0udczngGxV/vf2nvK1djqpOKIxY/+8rBWxAbWGRE4RnnwxWabDwJN3pCwIQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.68.2.tgz", + "integrity": "sha512-KBpm48/lESsHgWd+dRlcy18APBYhXU4Jb6VlJoqbpWNwfpztFXwP22qVv9aHd3k1quSrmLeJwYLc7rpQ+BFZrw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.68.2.tgz", + "integrity": "sha512-o0D0bfRW8QGA1Ph6OzqVHMq5LRu1xkr1iM7qQIXUSFuR60ddXeDhN9UR4bUBPLYsrT46sZwwgQa51TWtBV3r5g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.68.2.tgz", + "integrity": "sha512-r17kcu5kmd6WQwokYmfBnfwM/icureCWCPjpJVALcrSv5Lfy6Ggk9azxXor6hILhCHbc/4IfEiv+L5RXaOHinA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.68.2.tgz", + "integrity": "sha512-yUtOqq7ZrQoZ3WiHSR6QGTdOl4YgMHqXIYSBYU6siIcC0YF0pEwx7aGsPTm2mRwrmW6SMJkxzEdFm6wqXpmbNw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.68.2.tgz", + "integrity": "sha512-5IYoWxQGo5WECbJbImIf2w33uCHJNLv4o/FQtSyeYDed7AC6zx84NsEcGYccoI2geDEYkrxUXcsYK/6EhwVSIg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.68.2.tgz", + "integrity": "sha512-ee+c14ggUiM7lg4PtCjSBYU9O9dHp4FFespRnd5yj7SilUBJCL3x3aHlB+sIqbGjcPo3pEyODASnfKJuZ26YBw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/esrecurse": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz", + "integrity": "sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", + "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "20.19.43", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.43.tgz", + "integrity": "sha512-6oYBAi5ikg4Pl+kGsoYtawUMBT2zZMCvPNF7pVLnHZfd1zf38DRiWn/gT01RYCdUqkv7Fhr+C9ot4/tb+2sVvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.72.2.tgz", + "integrity": "sha512-222PKFXKihmFpi/pS5njoBgdAqsPhj2/GBmFbrNw8Tq8gEG9Sv+kSlKFy4u2q+mJv9ZzJgM2Gkv/bUzRZwZw5g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.72.2", + "@typescript-eslint/type-utils": "8.72.2", + "@typescript-eslint/utils": "8.72.2", + "@typescript-eslint/visitor-keys": "8.72.2", + "ignore": "^7.0.5", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.72.2", + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.14", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.14.tgz", + "integrity": "sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.72.2.tgz", + "integrity": "sha512-llP+T1YuJOLlxEciP6OyQGtz5SMxyn+9LA2BvZw5RmToGVa1y4beEDVQL6Gje7T5WFYh19WREjDCN9Ev4gm5AA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.72.2", + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/typescript-estree": "8.72.2", + "@typescript-eslint/visitor-keys": "8.72.2", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.72.2.tgz", + "integrity": "sha512-6y5dLTZdHhI8Eh3yIQ/bfQhRKwn5e+TpJj64o18Cngc0iW/BCrVvrr6zGYqXPnYH31u6YXAYiFh0+qxX5mybJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.72.2", + "@typescript-eslint/types": "^8.72.2", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.72.2.tgz", + "integrity": "sha512-iIoMJ6/8c1/QpFNyFjU0d1YzPco4MsZjQw0k3V+vfzNWAFmUmvhlyMoYEoYYDQZXc+J6Gi1X5XcxlzW2taIIGQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/visitor-keys": "8.72.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.72.2.tgz", + "integrity": "sha512-+h3iCgZXuTNtoLXcnnjP12ZUHLMqoUcIHPfQrFEXTUqvb9dF8QK9b5nv5VtSo5fLkdHuks8ehbTzZj3rImAm9w==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.72.2.tgz", + "integrity": "sha512-STfkR38qIdhfkLpgtXnUjAzsNy4xouqiBO0lrVc/Wpk9Kem5/aHXUx1J8dGC16zpdYN1+yc2ILQ28er1kXX7ag==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/typescript-estree": "8.72.2", + "@typescript-eslint/utils": "8.72.2", + "debug": "^4.4.3", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.72.2.tgz", + "integrity": "sha512-Xfn37OLZx03+PCU7qWx9DTv2FCRh1E6fk2+wONeNY15HXIwtcwuveaSwVpGAUptkNmPQegRxW5JyRel9T7wrog==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.72.2.tgz", + "integrity": "sha512-pQEGqIK/cqEvKivVWaFLYpe7XYejFxfuAOi4mu1oAWFvIo36aRHI9esRFTUxcIy/z8N482RJyH+LpZB0ZIU7Ow==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.72.2", + "@typescript-eslint/tsconfig-utils": "8.72.2", + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/visitor-keys": "8.72.2", + "debug": "^4.4.3", + "minimatch": "^10.2.2", + "semver": "^7.7.3", + "tinyglobby": "^0.2.15", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.72.2.tgz", + "integrity": "sha512-hv3eRYbpPbbpezuax1EfGrzpa3C4ySgNZkPUkLOWOAjU8HsOKowEDAr8C7nsNl1C+SBSKDpvno6VKHnlhvp9iA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.72.2", + "@typescript-eslint/types": "8.72.2", + "@typescript-eslint/typescript-estree": "8.72.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.72.2.tgz", + "integrity": "sha512-NAGrjn0Pitjqzq/GkgMC4kBYm233PQ8GffyQ9+kTA3AlNQYEzOf25EIM02BAHZv5FRJSpHpJk+OGUxVkOB93GQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.72.2", + "eslint-visitor-keys": "^5.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@vitest/expect": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.7.tgz", + "integrity": "sha512-E8eBXaKibuvH2pSZErOjdVb5vF4PbKYcrnluBTYxEk1l/VhhwZg1kZQsdtjq+CsF5CFydf2Rdkz7jDHKSisi3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/spy": "3.2.7", + "@vitest/utils": "3.2.7", + "chai": "^5.2.0", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.7.tgz", + "integrity": "sha512-Trr0hYO9CM3Wj6ksWHRhK9IZpIY6wTMO5u/MqXurMxT57sWBaOPEtP3Oq60ihZuh5JsiagKfz95OcxdEP6dBrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "3.2.7", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.17" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.7.tgz", + "integrity": "sha512-KUHlwqVu0sRlhCdyPdQ/wBoTfRahjUky1MubOmYw9fWfIZy1gNoHpuaaQBPAaMaVYdQYHJLurzj8ECCj5OwTqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.7.tgz", + "integrity": "sha512-sB9y4ovltoQP+WaUPwmSxO9WIg9Ig694Di5PalVPsYHklAdE027mehpWF2SQSVq+k6sFgaivbTjTJwZLSHbedA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "3.2.7", + "pathe": "^2.0.3", + "strip-literal": "^3.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.7.tgz", + "integrity": "sha512-7C+MwShwtBSI5Buwoyg3s/iY1eHL9PKAf+O1wVh/TdnjXUtkoL/9YQtre90i4MtNXM6edP1wJ2zOBpfCyhIS7g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "3.2.7", + "magic-string": "^0.30.17", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.7.tgz", + "integrity": "sha512-Q2eQGI6d2L/hBtZ0qNuKcAGid68XK6cv1xsoaIma6PaJhHPoqcEJhYpXZ/5myCMqkNgtP6UKuBhbc0nHKnrkuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyspy": "^4.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.7.tgz", + "integrity": "sha512-x6BDOd7dyo3PFLY3I9/HJ25X/6OurhGXk2/B9gOZNPF7XDVjeBK4k01lQE5uvDpbuheErh91qYuE1E2OEjK3Rw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "3.2.7", + "loupe": "^3.1.4", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/acorn": { + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", + "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/cacheable": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/cacheable/-/cacheable-2.5.0.tgz", + "integrity": "sha512-60cyAOytib/OzBw1JNSoSV/boK1AtHryDIjvVBk7XbN4ugfkM3+Sry7fEjNgPMGgOjuaZPAp8ruZ0Cxafwyq9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cacheable/memory": "^2.2.0", + "@cacheable/utils": "^2.5.0", + "hookified": "^1.15.0", + "keyv": "^5.6.0", + "qified": "^0.10.1" + } + }, + "node_modules/chai": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz", + "integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/check-error": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.3.tgz", + "integrity": "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 16" + } + }, + "node_modules/commander": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz", + "integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/es-module-lexer": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", + "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "10.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.14.0.tgz", + "integrity": "sha512-T0pNsxkb9IKmtQjhpK3d7nWOpFv+YHuMbTJnSVMoQblF0onvXfErrtp4V1jHtsQPan7dKaGVD0q1WCXnzMF31A==", + "dev": true, + "license": "MIT", + "workspaces": [ + "packages/*" + ], + "dependencies": { + "@eslint-community/eslint-utils": "^4.8.0", + "@eslint-community/regexpp": "^4.12.2", + "@eslint/config-array": "^0.23.5", + "@eslint/config-helpers": "^0.7.0", + "@eslint/core": "^1.2.1", + "@eslint/plugin-kit": "^0.7.3", + "@humanfs/node": "^0.16.8", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "ajv": "^6.14.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^9.1.2", + "eslint-visitor-keys": "^5.0.1", + "espree": "^11.2.0", + "esquery": "^1.7.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "11.1.5 || >11.1.6 <12", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "minimatch": "^10.2.6", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-config-prettier": { + "version": "10.1.8", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.8.tgz", + "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", + "dev": true, + "license": "MIT", + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "funding": { + "url": "https://opencollective.com/eslint-config-prettier" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-scope": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-9.1.2.tgz", + "integrity": "sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@types/esrecurse": "^4.3.1", + "@types/estree": "^1.0.8", + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-11.2.0.tgz", + "integrity": "sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.16.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^5.0.1" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", + "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/expect-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/file-entry-cache": { + "version": "11.1.5", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-11.1.5.tgz", + "integrity": "sha512-+PFTHITI08JIGhnNpGNI8T8inUpgZfk3GNEqfT9R2zZV2iFXg3CvqzSl/uEhs7TSGujYRELEANyDvS8Fj7+S7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^6.1.23" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "6.1.23", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-6.1.23.tgz", + "integrity": "sha512-f++BY9pTk+983xK1FLzlLpmM0i0z+jHmx3QESGkURMXujQZz1k5wzwX6hjnQ8goaD0B+sYnDK1yZ6MTyZfUaqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cacheable": "^2.5.0", + "flatted": "^3.4.2", + "hookified": "^1.15.0" + } + }, + "node_modules/flatted": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.4.tgz", + "integrity": "sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==", + "dev": true, + "license": "ISC" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "16.5.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-16.5.0.tgz", + "integrity": "sha512-c/c15i26VrJ4IRt5Z89DnIzCGDn9EcebibhAOjw5ibqEHsE1wLUgkPn9RDmNcUKyU87GeaL633nyJ+pplFR2ZQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/hashery": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/hashery/-/hashery-1.5.1.tgz", + "integrity": "sha512-iZyKG96/JwPz1N55vj2Ie2vXbhu440zfUfJvSwEqEbeLluk7NnapfGqa7LH0mOsnDxTF85Mx8/dyR6HfqcbmbQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "hookified": "^1.15.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/hookified": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-1.15.1.tgz", + "integrity": "sha512-MvG/clsADq1GPM2KGo2nyfaWVyn9naPiXrqIe4jYjXNZQt238kWyOGrsyc/DmRAQ+Re6yeo6yX/yoNCG5KAEVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/js-tokens": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", + "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/keyv": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.6.0.tgz", + "integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@keyv/serialize": "^1.1.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/loupe": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", + "integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/pathval": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz", + "integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.16" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.32", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.32.tgz", + "integrity": "sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.10.tgz", + "integrity": "sha512-skGHTH1Yb9QvaTC4hWnRTzEYtCpApF0UMBPz+t/0ZPzP8ihefo/btKd+QA7pUE0fEwA1SbS/NmhyEcstdXOIdA==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/qified": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/qified/-/qified-0.10.1.tgz", + "integrity": "sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hookified": "^2.1.1" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/qified/node_modules/hookified": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/hookified/-/hookified-2.2.0.tgz", + "integrity": "sha512-p/LgFzRN5FeoD3DLS6bkUapeye6E4SI6yJs6KetENd18S+FBthqYq2amJUWpt5z0EQwwHemidjY5OqJGEKm5uA==", + "dev": true, + "license": "MIT" + }, + "node_modules/rollup": { + "version": "4.68.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.68.2.tgz", + "integrity": "sha512-xzt45rKOxzEuqjTdkGTIEaePcq9xRELlFI1uoazlKap8T6bENJkONSCfhK51P6XFTixa4rosPcDHihSdduXndQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.10" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.68.2", + "@rollup/rollup-android-arm64": "4.68.2", + "@rollup/rollup-android-x64": "4.68.2", + "@rollup/rollup-darwin-arm64": "4.68.2", + "@rollup/rollup-darwin-x64": "4.68.2", + "@rollup/rollup-freebsd-arm64": "4.68.2", + "@rollup/rollup-freebsd-x64": "4.68.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.68.2", + "@rollup/rollup-linux-arm-musleabihf": "4.68.2", + "@rollup/rollup-linux-arm64-gnu": "4.68.2", + "@rollup/rollup-linux-arm64-musl": "4.68.2", + "@rollup/rollup-linux-loong64-gnu": "4.68.2", + "@rollup/rollup-linux-loong64-musl": "4.68.2", + "@rollup/rollup-linux-ppc64-gnu": "4.68.2", + "@rollup/rollup-linux-ppc64-musl": "4.68.2", + "@rollup/rollup-linux-riscv64-gnu": "4.68.2", + "@rollup/rollup-linux-riscv64-musl": "4.68.2", + "@rollup/rollup-linux-s390x-gnu": "4.68.2", + "@rollup/rollup-linux-x64-gnu": "4.68.2", + "@rollup/rollup-linux-x64-musl": "4.68.2", + "@rollup/rollup-openbsd-x64": "4.68.2", + "@rollup/rollup-openharmony-arm64": "4.68.2", + "@rollup/rollup-win32-arm64-msvc": "4.68.2", + "@rollup/rollup-win32-ia32-msvc": "4.68.2", + "@rollup/rollup-win32-x64-gnu": "4.68.2", + "@rollup/rollup-win32-x64-msvc": "4.68.2", + "fsevents": "~2.3.2" + } + }, + "node_modules/semver": { + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", + "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==", + "dev": true, + "license": "MIT" + }, + "node_modules/strip-literal": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.1.0.tgz", + "integrity": "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^9.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", + "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinypool": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz", + "integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "node_modules/tinyrainbow": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz", + "integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.6.tgz", + "integrity": "sha512-u8KszXvGfU68hVcZpRHKG28T0krMuv2G5nDhiHaMLen/gIuFEgIJhaJuO69qjnXg5paSrbPMFfx3brNuN8eVSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/ts-api-utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", + "integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/typescript": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/typescript-eslint": { + "version": "8.72.2", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.72.2.tgz", + "integrity": "sha512-c/+AKMW1KB81r28Sp0AAdcyXj5dzNmAsZFcsrxKbZTKmcBK2xIwBR31dcSYSDu3bKmzXe8GKrSxO+eDQ401Uzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.72.2", + "@typescript-eslint/parser": "8.72.2", + "@typescript-eslint/typescript-estree": "8.72.2", + "@typescript-eslint/utils": "8.72.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/vite": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.8.tgz", + "integrity": "sha512-3tTi78MAKhVk9h+YZVXMQ8POmneJuE97QUPAWtJghHzhH7BAyiqQOC2KZh1DWOsu/USB2cRXhznPByaabvYXfw==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.27.0 || ^0.28.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz", + "integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.4.1", + "es-module-lexer": "^1.7.0", + "pathe": "^2.0.3", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vitest": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.7.tgz", + "integrity": "sha512-KrxIJ62Fd89gfysR4WotlgZABiz2dqFPgqGzX7s+CwsqLFomRH7777ZcrOD6+WVAh7khPQP41A+BKbpcJFrdEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/expect": "3.2.7", + "@vitest/mocker": "3.2.7", + "@vitest/pretty-format": "^3.2.7", + "@vitest/runner": "3.2.7", + "@vitest/snapshot": "3.2.7", + "@vitest/spy": "3.2.7", + "@vitest/utils": "3.2.7", + "chai": "^5.2.0", + "debug": "^4.4.1", + "expect-type": "^1.2.1", + "magic-string": "^0.30.17", + "pathe": "^2.0.3", + "picomatch": "^4.0.2", + "std-env": "^3.9.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.2", + "tinyglobby": "^0.2.14", + "tinypool": "^1.1.1", + "tinyrainbow": "^2.0.0", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", + "vite-node": "3.2.4", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/debug": "^4.1.12", + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "@vitest/browser": "3.2.7", + "@vitest/ui": "3.2.7", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/debug": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/data-agent-cli/package.json b/data-agent-cli/package.json new file mode 100644 index 00000000..892acddb --- /dev/null +++ b/data-agent-cli/package.json @@ -0,0 +1,69 @@ +{ + "name": "@malone-talk/data-agent-cli", + "version": "1.0.0", + "description": "CLI for calling DataAgent agent tools over REST with a personal access token.", + "type": "module", + "bin": { + "data-agent-cli": "dist/index.js" + }, + "files": [ + "dist" + ], + "engines": { + "node": ">=20" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "build": "tsc", + "test": "vitest run", + "lint": "eslint . --fix", + "lint:check": "eslint .", + "format": "prettier --write .", + "format:check": "prettier --check .", + "typecheck": "tsc --noEmit" + }, + "dependencies": { + "commander": "^13.1.0" + }, + "devDependencies": { + "@eslint/js": "^10.0.1", + "@types/node": "^20.17.30", + "eslint": "^10.0.0", + "eslint-config-prettier": "^10.1.1", + "globals": "^16.0.0", + "prettier": "^3.5.3", + "typescript": "~5.6.2", + "typescript-eslint": "^8.18.1", + "vitest": "^3.0.8" + }, + "license": "AGPL-3.0-or-later", + "author": { + "name": "MaloneTalk", + "url": "https://github.com/MaloneTalk" + }, + "contributors": [ + { + "name": "lzq", + "url": "https://github.com/lzq986" + }, + { + "name": "VLSMB", + "url": "https://github.com/VLSMB" + }, + { + "name": "mengnankkkk", + "url": "https://github.com/mengnankkkk" + } + ], + "repository": { + "type": "git", + "url": "git+https://github.com/MaloneTalk/DataAgent.git", + "directory": "data-agent-cli" + }, + "homepage": "https://github.com/MaloneTalk/DataAgent", + "bugs": { + "url": "https://github.com/MaloneTalk/DataAgent/issues" + } +} diff --git a/data-agent-cli/src/client/DataAgentClient.ts b/data-agent-cli/src/client/DataAgentClient.ts new file mode 100644 index 00000000..e5fd8af9 --- /dev/null +++ b/data-agent-cli/src/client/DataAgentClient.ts @@ -0,0 +1,210 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { DEFAULT_SESSION_KEY } from '../trace/store.js'; +import { CliError, ExitCode } from '../errors.js'; + +export interface UserPatVo { + id: number; + name: string; + tokenPrefix: string; + expiresAt: string; + lastUsedAt?: string | null; + revokedAt?: string | null; + createTime: string; +} + +export interface AgentToolVo { + name: string; + description: string; + parameters: Record; +} + +export interface ToolResultVo { + text: string; + metadata: Record; + traceId?: string | null; +} + +export interface TraceProvider { + (sessionKey: string): Promise<{ traceparent: string; traceId: string }>; +} + +export interface DataAgentClientOptions { + baseUrl: string; + token: string; + timeoutMs: number; + version: string; + sessionId?: string; + verbose?: boolean; + logger?: (message: string) => void; + traceProvider: TraceProvider; +} + +interface ApiEnvelope { + code: number; + errorCode?: string | null; + message?: string; + data?: T; +} + +export class DataAgentClient { + private readonly baseUrl: string; + private readonly token: string; + private readonly timeoutMs: number; + private readonly version: string; + private readonly sessionId?: string; + private readonly verbose: boolean; + private readonly logger?: (message: string) => void; + private readonly traceProvider: TraceProvider; + + constructor(options: DataAgentClientOptions) { + this.baseUrl = options.baseUrl; + this.token = options.token; + this.timeoutMs = options.timeoutMs; + this.version = options.version; + this.sessionId = options.sessionId; + this.verbose = Boolean(options.verbose); + this.logger = options.logger; + this.traceProvider = options.traceProvider; + } + + health(): Promise { + return this.request('GET', '/agent/health'); + } + + listTools(): Promise { + return this.request('GET', '/agent/tools'); + } + + async callTool(name: string, input: Record): Promise { + const result = await this.request( + 'POST', + `/agent/tools/${encodeURIComponent(name)}`, + input, + ); + return { ...result, metadata: result.metadata ?? {} }; + } + + private async request(method: string, path: string, body?: unknown): Promise { + const sessionKey = this.sessionId ?? DEFAULT_SESSION_KEY; + const trace = await this.traceProvider(sessionKey); + const headers: Record = { + Accept: 'application/json', + Authorization: `Bearer ${this.token}`, + 'User-Agent': `data-agent-cli/${this.version}`, + traceparent: trace.traceparent, + }; + if (this.sessionId) { + headers['X-Session-Id'] = this.sessionId; + } + if (body !== undefined) { + headers['Content-Type'] = 'application/json'; + } + + const controller = new AbortController(); + const timer = setTimeout(() => controller.abort(), this.timeoutMs); + this.log(`${method} ${path}`); + try { + const response = await fetch(`${this.baseUrl}${path}`, { + method, + headers, + body: body === undefined ? undefined : JSON.stringify(body), + signal: controller.signal, + }); + this.log(`${method} ${path} -> ${response.status}`); + const text = await response.text(); + const envelope = parseEnvelope(text); + if (!response.ok) { + throw httpError(response.status, envelope); + } + if (envelope === undefined) { + throw new CliError(ExitCode.Server, 'INVALID_RESPONSE', 'Server returned empty response.'); + } + if (envelope.code !== 200 || envelope.errorCode) { + throw envelopeError(envelope); + } + return envelope.data as T; + } catch (error) { + if (error instanceof CliError) { + throw error; + } + if (isAbortError(error)) { + throw new CliError( + ExitCode.Network, + 'TIMEOUT', + `Request timed out after ${this.timeoutMs} ms.`, + ); + } + const message = error instanceof Error ? error.message : String(error); + throw new CliError(ExitCode.Network, 'NETWORK_ERROR', `Request failed: ${message}`); + } finally { + clearTimeout(timer); + } + } + + private log(message: string): void { + if (this.verbose && this.logger) { + this.logger(message); + } + } +} + +function parseEnvelope(text: string): ApiEnvelope | undefined { + if (!text.trim()) { + return undefined; + } + let parsed: unknown; + try { + parsed = JSON.parse(text); + } catch { + throw new CliError(ExitCode.Server, 'INVALID_RESPONSE', 'Server returned invalid JSON.'); + } + if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) { + throw new CliError(ExitCode.Server, 'INVALID_RESPONSE', 'Server returned unexpected JSON.'); + } + return parsed as ApiEnvelope; +} + +function httpError(status: number, envelope: ApiEnvelope | undefined): CliError { + const errorCode = envelope?.errorCode || `HTTP_${status}`; + const message = envelope?.message || `Request failed with HTTP ${status}.`; + return new CliError(statusExitCode(status), errorCode, message); +} + +function envelopeError(envelope: ApiEnvelope): CliError { + const status = typeof envelope.code === 'number' ? envelope.code : 500; + return new CliError( + statusExitCode(status), + envelope.errorCode || 'REQUEST_FAILED', + envelope.message || 'Request failed.', + ); +} + +function statusExitCode(status: number): ExitCode { + if (status === 401 || status === 403) { + return ExitCode.Auth; + } + if (status === 400 || status === 409 || status === 422) { + return ExitCode.Usage; + } + return ExitCode.Server; +} + +function isAbortError(error: unknown): boolean { + return error instanceof Error && error.name === 'AbortError'; +} diff --git a/data-agent-cli/src/commands/auth.ts b/data-agent-cli/src/commands/auth.ts new file mode 100644 index 00000000..8053b1d7 --- /dev/null +++ b/data-agent-cli/src/commands/auth.ts @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import type { Command } from 'commander'; +import { DataAgentClient } from '../client/DataAgentClient.js'; +import { loadConfig, resolveBaseUrl, resolveTimeoutSeconds, saveConfig } from '../config/store.js'; +import type { CommonOptions } from '../options.js'; +import { + expiryWarning, + isJsonMode, + printAuthStatus, + printJson, + printText, + warn, +} from '../output.js'; +import { promptToken } from '../prompt.js'; +import { nextTrace } from '../trace/store.js'; +import { VERSION } from '../version.js'; +import { addCommonOptions, createRuntime } from './common.js'; + +export function registerAuthCommands(program: Command): void { + const auth = program.command('auth').description('Manage PAT authentication'); + + const login = addCommonOptions(auth.command('login').description('Validate and save a PAT')); + login.action(async () => { + const options = login.opts(); + const config = await loadConfig(); + const baseUrl = resolveBaseUrl(options, config); + const timeoutSeconds = resolveTimeoutSeconds(options, config); + const token = options.token ?? process.env.DATAAGENT_TOKEN ?? (await promptToken()); + const client = new DataAgentClient({ + baseUrl, + token, + timeoutMs: timeoutSeconds * 1000, + version: VERSION, + verbose: options.verbose, + logger: options.verbose ? line => process.stderr.write(`${line}\n`) : undefined, + traceProvider: sessionKey => nextTrace(sessionKey), + }); + + const pat = await client.health(); + await saveConfig({ baseUrl, token, timeoutSeconds }); + if (isJsonMode(options.json)) { + printJson(pat); + } else { + printText(`Logged in to ${baseUrl}`); + printAuthStatus(pat); + } + const warning = expiryWarning(pat); + if (warning) { + warn(warning); + } + }); + + const status = addCommonOptions(auth.command('status').description('Check the current PAT')); + status.action(async () => { + const options = status.opts(); + const runtime = await createRuntime(options); + const pat = await runtime.client.health(); + if (isJsonMode(options.json)) { + printJson(pat); + } else { + printAuthStatus(pat); + } + const warning = expiryWarning(pat); + if (warning) { + warn(warning); + } + }); + + const logout = addCommonOptions(auth.command('logout').description('Remove the local PAT')); + logout.action(async () => { + const options = logout.opts(); + const config = await loadConfig(); + await saveConfig({ ...config, token: undefined }); + if (isJsonMode(options.json)) { + printJson({ status: 'logged_out' }); + } else { + printText('Logged out. PAT was removed from the local config.'); + } + }); +} diff --git a/data-agent-cli/src/commands/common.ts b/data-agent-cli/src/commands/common.ts new file mode 100644 index 00000000..e6db7b2d --- /dev/null +++ b/data-agent-cli/src/commands/common.ts @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import type { Command } from 'commander'; +import { + loadConfig, + resolveBaseUrl, + resolveSessionId, + resolveTimeoutSeconds, + resolveToken, + type Config, +} from '../config/store.js'; +import { DataAgentClient } from '../client/DataAgentClient.js'; +import type { CommonOptions } from '../options.js'; +import { nextTrace } from '../trace/store.js'; +import { VERSION } from '../version.js'; + +export interface Runtime { + client: DataAgentClient; + config: Config; + baseUrl: string; + token: string; + timeoutSeconds: number; + sessionId?: string; + options: CommonOptions; +} + +export function addCommonOptions(command: Command): Command { + return command + .option('--base-url ', 'DataAgent base URL') + .option('--token ', 'personal access token') + .option('--session-id ', 'session id sent as X-Session-Id') + .option('--json', 'output JSON') + .option('--timeout ', 'request timeout in seconds') + .option('--verbose', 'print request details to stderr'); +} + +export async function createRuntime(options: CommonOptions): Promise { + const config = await loadConfig(); + const baseUrl = resolveBaseUrl(options, config); + const token = resolveToken(options, config); + const timeoutSeconds = resolveTimeoutSeconds(options, config); + const sessionId = resolveSessionId(options); + const client = new DataAgentClient({ + baseUrl, + token, + timeoutMs: timeoutSeconds * 1000, + version: VERSION, + sessionId, + verbose: options.verbose, + logger: options.verbose ? line => process.stderr.write(`${line}\n`) : undefined, + traceProvider: sessionKey => nextTrace(sessionKey), + }); + return { client, config, baseUrl, token, timeoutSeconds, sessionId, options }; +} diff --git a/data-agent-cli/src/commands/skill.ts b/data-agent-cli/src/commands/skill.ts new file mode 100644 index 00000000..d6af2a02 --- /dev/null +++ b/data-agent-cli/src/commands/skill.ts @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import type { Command } from 'commander'; +import { DATA_QUERY_SKILL } from '../skill/data-query.js'; + +export function registerSkillCommand(program: Command): void { + program + .command('skill') + .description('Print the agent guide for data query workflows') + .action(() => { + process.stdout.write( + DATA_QUERY_SKILL.endsWith('\n') ? DATA_QUERY_SKILL : DATA_QUERY_SKILL + '\n', + ); + }); +} diff --git a/data-agent-cli/src/commands/tools.ts b/data-agent-cli/src/commands/tools.ts new file mode 100644 index 00000000..f9cc48cb --- /dev/null +++ b/data-agent-cli/src/commands/tools.ts @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import type { Command } from 'commander'; +import { CliError, ExitCode } from '../errors.js'; +import { readInput } from '../input.js'; +import type { CallOptions, CommonOptions } from '../options.js'; +import { + isJsonMode, + printJson, + printToolDescription, + printToolResult, + printTools, +} from '../output.js'; +import { addCommonOptions, createRuntime } from './common.js'; + +export function registerToolsCommands(program: Command): void { + const tools = program.command('tools').description('Discover and call agent tools'); + + const list = addCommonOptions(tools.command('list').description('List available tools')); + list.action(async () => { + const options = list.opts(); + const runtime = await createRuntime(options); + const result = await runtime.client.listTools(); + if (isJsonMode(options.json)) { + printJson(result); + } else { + printTools(result); + } + }); + + const describe = addCommonOptions( + tools.command('describe ').description('Show a tool definition'), + ); + describe.action(async (name: string) => { + const options = describe.opts(); + const runtime = await createRuntime(options); + const result = await runtime.client.listTools(); + const tool = result.find(candidate => candidate.name === name); + if (!tool) { + throw new CliError(ExitCode.Usage, 'TOOL_NOT_FOUND', `Unknown tool: ${name}`); + } + if (isJsonMode(options.json)) { + printJson(tool); + } else { + printToolDescription(tool); + } + }); + + const call = addCommonOptions( + tools.command('call ').description('Call a tool with JSON input'), + ); + call.requiredOption('--input ', 'JSON object, @file, or - for stdin'); + call.action(async (name: string) => { + const options = call.opts(); + const runtime = await createRuntime(options); + const input = await readInput(options.input); + const result = await runtime.client.callTool(name, input); + if (isJsonMode(options.json)) { + printJson(result); + } else { + printToolResult(result); + } + if (typeof result.metadata.errorCode === 'string' && result.metadata.errorCode) { + process.exitCode = ExitCode.Server; + } + }); +} diff --git a/data-agent-cli/src/config/store.ts b/data-agent-cli/src/config/store.ts new file mode 100644 index 00000000..157dd184 --- /dev/null +++ b/data-agent-cli/src/config/store.ts @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { chmod, mkdir, readFile, rename, writeFile } from 'node:fs/promises'; +import { homedir } from 'node:os'; +import { dirname, join } from 'node:path'; +import { CliError, ExitCode } from '../errors.js'; +import type { CommonOptions } from '../options.js'; + +export const DEFAULT_BASE_URL = 'http://localhost:8080'; +export const DEFAULT_TIMEOUT_SECONDS = 60; + +export interface Config { + baseUrl: string; + token?: string; + timeoutSeconds?: number; +} + +export function defaultConfigDir(env: NodeJS.ProcessEnv = process.env): string { + if (process.platform === 'win32') { + return join(env.APPDATA ?? join(homedir(), 'AppData', 'Roaming'), 'data-agent-cli'); + } + return join(env.XDG_CONFIG_HOME ?? join(homedir(), '.config'), 'data-agent-cli'); +} + +export function configFilePath(dir = defaultConfigDir()): string { + return join(dir, 'config.json'); +} + +export function stateFilePath(dir = defaultConfigDir()): string { + return join(dir, 'state.json'); +} + +export async function loadConfig(dir = defaultConfigDir()): Promise { + const path = configFilePath(dir); + let text: string; + try { + text = await readFile(path, 'utf8'); + } catch (error) { + if (isNotFound(error)) { + return { baseUrl: DEFAULT_BASE_URL }; + } + throw new CliError(ExitCode.Usage, 'CONFIG_READ_FAILED', `Cannot read config: ${path}`); + } + + let parsed: unknown; + try { + parsed = JSON.parse(text); + } catch { + throw new CliError(ExitCode.Usage, 'CONFIG_INVALID', `Invalid JSON config: ${path}`); + } + if (!isRecord(parsed)) { + throw new CliError(ExitCode.Usage, 'CONFIG_INVALID', `Config must be an object: ${path}`); + } + + return { + baseUrl: + typeof parsed.baseUrl === 'string' && parsed.baseUrl.trim() + ? parsed.baseUrl.trim() + : DEFAULT_BASE_URL, + token: + typeof parsed.token === 'string' && parsed.token.trim() ? parsed.token.trim() : undefined, + timeoutSeconds: + typeof parsed.timeoutSeconds === 'number' && parsed.timeoutSeconds > 0 + ? parsed.timeoutSeconds + : undefined, + }; +} + +export async function saveConfig(config: Config, dir = defaultConfigDir()): Promise { + const path = configFilePath(dir); + await mkdir(dirname(path), { recursive: true, mode: 0o700 }); + const temporary = `${path}.${process.pid}.tmp`; + const body = JSON.stringify(config, null, 2) + '\n'; + await writeFile(temporary, body, { mode: 0o600 }); + await rename(temporary, path); + try { + await chmod(path, 0o600); + } catch { + // Windows 上 chmod 可能不支持。 + } +} + +export function normalizeBaseUrl(value: string): string { + let url: URL; + try { + url = new URL(value); + } catch { + throw new CliError(ExitCode.Usage, 'INVALID_BASE_URL', `Invalid base URL: ${value}`); + } + if (url.protocol !== 'http:' && url.protocol !== 'https:') { + throw new CliError(ExitCode.Usage, 'INVALID_BASE_URL', 'Base URL must use http or https.'); + } + return url.toString().replace(/\/+$/, ''); +} + +export function resolveBaseUrl(options: CommonOptions, config: Config): string { + return normalizeBaseUrl( + options.baseUrl ?? config.baseUrl ?? process.env.DATAAGENT_BASE_URL ?? DEFAULT_BASE_URL, + ); +} + +export function resolveToken(options: CommonOptions, config: Config): string { + const token = options.token ?? config.token ?? process.env.DATAAGENT_TOKEN; + if (!token) { + throw new CliError( + ExitCode.Auth, + 'UNAUTHORIZED', + 'No PAT configured. Run `data-agent-cli auth login`.', + ); + } + return token; +} + +export function resolveTimeoutSeconds(options: CommonOptions, config: Config): number { + const raw = options.timeout ?? config.timeoutSeconds ?? DEFAULT_TIMEOUT_SECONDS; + const seconds = Number(raw); + if (!Number.isFinite(seconds) || seconds <= 0) { + throw new CliError(ExitCode.Usage, 'INVALID_TIMEOUT', 'Timeout must be a positive number.'); + } + return seconds; +} + +export function resolveSessionId(options: CommonOptions): string | undefined { + const sessionId = options.sessionId ?? process.env.DATAAGENT_SESSION_ID; + return sessionId?.trim() || undefined; +} + +function isRecord(value: unknown): value is Record { + return typeof value === 'object' && value !== null && !Array.isArray(value); +} + +function isNotFound(error: unknown): boolean { + return typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT'; +} diff --git a/data-agent-cli/src/errors.ts b/data-agent-cli/src/errors.ts new file mode 100644 index 00000000..a988198a --- /dev/null +++ b/data-agent-cli/src/errors.ts @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +export enum ExitCode { + Success = 0, + Usage = 2, + Auth = 3, + Network = 4, + Server = 5, +} + +export class CliError extends Error { + readonly exitCode: ExitCode; + readonly errorCode: string; + + constructor(exitCode: ExitCode, errorCode: string, message: string) { + super(message); + this.name = 'CliError'; + this.exitCode = exitCode; + this.errorCode = errorCode; + } +} + +export interface ErrorPayload { + errorCode: string; + message: string; +} + +export function toErrorPayload(error: unknown): ErrorPayload { + if (error instanceof CliError) { + return { errorCode: error.errorCode, message: error.message }; + } + if (error instanceof Error) { + return { errorCode: 'INTERNAL_ERROR', message: error.message }; + } + return { errorCode: 'INTERNAL_ERROR', message: String(error) }; +} + +export function exitCodeOf(error: unknown): ExitCode { + return error instanceof CliError ? error.exitCode : ExitCode.Server; +} diff --git a/data-agent-cli/src/index.ts b/data-agent-cli/src/index.ts new file mode 100644 index 00000000..a06fb35a --- /dev/null +++ b/data-agent-cli/src/index.ts @@ -0,0 +1,59 @@ +#!/usr/bin/env node +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { Command } from 'commander'; +import { registerAuthCommands } from './commands/auth.js'; +import { registerSkillCommand } from './commands/skill.js'; +import { registerToolsCommands } from './commands/tools.js'; +import { exitCodeOf } from './errors.js'; +import { printError } from './output.js'; +import { AUTHOR, CONTRIBUTORS, VERSION } from './version.js'; + +function versionText(): string { + const label = (person: { name: string; url?: string }) => + person.url ? `${person.name} <${person.url}>` : person.name; + const lines = [VERSION, '', 'Author:']; + if (AUTHOR) { + lines.push(label(AUTHOR)); + } + if (CONTRIBUTORS.length > 0) { + lines.push(...CONTRIBUTORS.map(person => ` ${label(person)}`)); + } + return lines.join('\n'); +} + +async function main(): Promise { + const program = new Command(); + program + .name('data-agent-cli') + .description('Call DataAgent agent tools with a personal access token') + .version(versionText(), '-v, --version') + .showSuggestionAfterError(); + + registerAuthCommands(program); + registerToolsCommands(program); + registerSkillCommand(program); + + await program.parseAsync(process.argv); +} + +main().catch(error => { + const json = process.argv.includes('--json') || !process.stdout.isTTY; + printError(error, json); + process.exitCode = exitCodeOf(error); +}); diff --git a/data-agent-cli/src/input.ts b/data-agent-cli/src/input.ts new file mode 100644 index 00000000..ff924c59 --- /dev/null +++ b/data-agent-cli/src/input.ts @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { readFile } from 'node:fs/promises'; +import { CliError, ExitCode } from './errors.js'; + +export async function readInput(value: string): Promise> { + const text = await readInputText(value); + return parseInputText( + text, + value === '-' ? 'stdin' : value.startsWith('@') ? value.slice(1) : '--input', + ); +} + +export function parseInputText(text: string, source: string): Record { + if (!text.trim()) { + throw new CliError(ExitCode.Usage, 'EMPTY_INPUT', `Empty JSON input from ${source}.`); + } + let parsed: unknown; + try { + parsed = JSON.parse(text); + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + throw new CliError( + ExitCode.Usage, + 'INVALID_INPUT', + `Invalid JSON input from ${source}: ${message}`, + ); + } + if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) { + throw new CliError(ExitCode.Usage, 'INVALID_INPUT', 'Tool input must be a JSON object.'); + } + return parsed as Record; +} + +async function readInputText(value: string): Promise { + if (value === '-') { + return readStdin(); + } + if (value.startsWith('@')) { + try { + return await readFile(value.slice(1), 'utf8'); + } catch { + throw new CliError( + ExitCode.Usage, + 'INPUT_FILE_NOT_FOUND', + `Cannot read input file: ${value.slice(1)}`, + ); + } + } + return value; +} + +async function readStdin(): Promise { + const chunks: Buffer[] = []; + for await (const chunk of process.stdin) { + chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)); + } + return Buffer.concat(chunks).toString('utf8'); +} diff --git a/data-agent-cli/src/options.ts b/data-agent-cli/src/options.ts new file mode 100644 index 00000000..948bd8fe --- /dev/null +++ b/data-agent-cli/src/options.ts @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +export interface CommonOptions { + baseUrl?: string; + token?: string; + sessionId?: string; + json?: boolean; + timeout?: string; + verbose?: boolean; +} + +export interface CallOptions extends CommonOptions { + input: string; +} diff --git a/data-agent-cli/src/output.ts b/data-agent-cli/src/output.ts new file mode 100644 index 00000000..4bd48bf6 --- /dev/null +++ b/data-agent-cli/src/output.ts @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { toErrorPayload } from './errors.js'; +import type { AgentToolVo, ToolResultVo, UserPatVo } from './client/DataAgentClient.js'; + +export function isJsonMode(flag: boolean | undefined): boolean { + return Boolean(flag) || !process.stdout.isTTY; +} + +export function printJson(value: unknown): void { + process.stdout.write(JSON.stringify(value, null, 2) + '\n'); +} + +export function printText(value: string): void { + process.stdout.write(value.endsWith('\n') ? value : value + '\n'); +} + +export function printError(error: unknown, json: boolean): void { + const payload = toErrorPayload(error); + if (json) { + printJson(payload); + } else { + printText(`${payload.errorCode}: ${payload.message}`); + } +} + +export function warn(message: string): void { + process.stderr.write(`warning: ${message}\n`); +} + +export function printTools(tools: AgentToolVo[]): void { + if (tools.length === 0) { + printText('No tools available.'); + return; + } + const nameWidth = Math.max('NAME'.length, ...tools.map(tool => tool.name.length)); + const lines = [ + `${'NAME'.padEnd(nameWidth)} REQUIRED DESCRIPTION`, + `${'-'.repeat(nameWidth)} -------- -----------`, + ]; + for (const tool of tools) { + const required = requiredParams(tool); + lines.push( + `${tool.name.padEnd(nameWidth)} ${(required.join(',') || '-').padEnd(8)} ${ + tool.description || '-' + }`, + ); + } + printText(lines.join('\n')); +} + +export function printToolDescription(tool: AgentToolVo): void { + printText( + [ + `Name: ${tool.name}`, + `Description: ${tool.description || '-'}`, + 'Parameters:', + JSON.stringify(tool.parameters, null, 2), + ].join('\n'), + ); +} + +export function printToolResult(result: ToolResultVo): void { + printText(result.text); +} + +export function printAuthStatus(pat: UserPatVo): void { + printText( + [ + `Token: ${pat.name} (${pat.tokenPrefix}...)`, + `Expires: ${pat.expiresAt}`, + `Last used: ${pat.lastUsedAt ?? '-'}`, + `Created: ${pat.createTime}`, + ].join('\n'), + ); +} + +export function expiryWarning(pat: UserPatVo, thresholdDays = 7): string | null { + const expiresAt = Date.parse(pat.expiresAt); + if (!Number.isFinite(expiresAt)) { + return null; + } + const remainingDays = (expiresAt - Date.now()) / 86_400_000; + if (remainingDays < 0) { + return `PAT "${pat.name}" has expired. Create a new one in /settings/tokens.`; + } + if (remainingDays <= thresholdDays) { + return `PAT "${pat.name}" expires in ${Math.ceil(remainingDays)} day(s).`; + } + return null; +} + +export function requiredParams(tool: AgentToolVo): string[] { + const required = tool.parameters.required; + return Array.isArray(required) + ? required.filter((value): value is string => typeof value === 'string') + : []; +} diff --git a/data-agent-cli/src/prompt.ts b/data-agent-cli/src/prompt.ts new file mode 100644 index 00000000..f0cf704a --- /dev/null +++ b/data-agent-cli/src/prompt.ts @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import readline from 'node:readline'; +import { CliError, ExitCode } from './errors.js'; + +type WritableInterface = readline.Interface & { + _writeToOutput?: (text: string) => void; +}; + +export async function promptToken(): Promise { + if (!process.stdin.isTTY) { + throw new CliError( + ExitCode.Usage, + 'TOKEN_REQUIRED', + 'No PAT provided. Use --token or DATAAGENT_TOKEN in non-interactive mode.', + ); + } + + process.stdout.write('PAT: '); + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + terminal: true, + }); + const writable = rl as WritableInterface; + const originalWrite = writable._writeToOutput; + writable._writeToOutput = () => {}; + + const token = await new Promise(resolve => { + rl.question('', answer => resolve(answer)); + }); + writable._writeToOutput = originalWrite; + rl.close(); + process.stdout.write('\n'); + + if (!token.trim()) { + throw new CliError(ExitCode.Usage, 'TOKEN_REQUIRED', 'PAT must not be empty.'); + } + return token.trim(); +} diff --git a/data-agent-cli/src/skill/data-query.ts b/data-agent-cli/src/skill/data-query.ts new file mode 100644 index 00000000..2f895201 --- /dev/null +++ b/data-agent-cli/src/skill/data-query.ts @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +export const DATA_QUERY_SKILL = `# DataAgent 问数指南 + +你是数据分析 Agent。你通过 data-agent-cli 调用 DataAgent 的只读工具, +自己负责理解问题、选择工具、编排调用并总结结果。 + +## 前置检查 + +先执行: + +~~~bash +data-agent-cli auth status +~~~ + +- 返回 0:PAT 有效,可以继续。 +- 返回 3:认证失败。请让用户执行 data-agent-cli auth login 重新登录, + 或到 /settings/tokens 创建新的 PAT。 +- 不要要求用户把 PAT 粘贴到对话里。 + +## 工具发现 + +不要猜测工具名和参数。先执行: + +~~~bash +data-agent-cli tools list +data-agent-cli tools describe +~~~ + +工具定义里的 parameters 是 JSON Schema。调用时使用 schema 中的参数名。 + +## 推荐问数流程 + +1. 获取数据源: + + ~~~bash + data-agent-cli tools call get_datasources --input '{}' + ~~~ + +2. 获取领域: + + ~~~bash + data-agent-cli tools call get_domains --input '{"datasource_id":1}' + ~~~ + +3. 按领域获取表: + + ~~~bash + data-agent-cli tools call get_tables --input '{"datasource_id":1,"domains":["sales"]}' + ~~~ + +4. 查看相关表结构: + + ~~~bash + data-agent-cli tools call get_table_schema --input '{"datasource_id":1,"table_name":"orders"}' + ~~~ + +5. 指标场景先查口径: + + ~~~bash + data-agent-cli tools call get_metric_caliber --input '{"datasource_id":1,"hint":"上个月GMV"}' + ~~~ + +6. 执行 SELECT: + + ~~~bash + data-agent-cli tools call execute_sql --input '{"datasource_id":1,"sql":"SELECT ..."}' + ~~~ + +7. 根据查询结果总结答案。不要伪造数据。 + +## 参数规则 + +- 工具参数统一通过 --input 传 JSON。 +- 多数据源时必须传 datasource_id;只有一个可选数据源时可以省略。 +- 不要伪造 tool name、参数名或字段名。 +- execute_sql 只允许 SELECT,不支持 INSERT/UPDATE/DELETE 等写操作。 +- execute_sql 最多返回 200 行;需要更多数据时使用 LIMIT/OFFSET 分页。 +- 不同数据源的同名表不能混用。 + +## session 规则 + +- 不要把 session_id 放进 --input。 +- 需要多次调用保持同一会话时,由调用方给 CLI 传: + + ~~~bash + data-agent-cli tools call get_tables --session-id run-123 --input '{"datasource_id":1}' + ~~~ + +- 也可以通过 DATAAGENT_SESSION_ID 环境变量提供。 +- 不提供时后端使用默认会话。 + +## 输出与错误 + +- 推荐使用 --json,或确保 stdout 不是 TTY。 +- stdout 输出数据或错误 JSON;stderr 输出日志和提示。 +- 通过退出码判断成功或失败: + - 0:成功 + - 2:参数或输入错误 + - 3:认证失败 + - 4:网络错误或超时 + - 5:服务端错误或工具执行失败 +- 工具执行失败时可能仍是 HTTP 200,需要检查 metadata.errorCode。 +- 不要依赖中文错误文案做逻辑判断,优先使用 errorCode。 + +## 示例:完整一次查询 + +~~~bash +data-agent-cli auth status + +data-agent-cli tools list + +data-agent-cli tools call get_domains \ + --input '{"datasource_id":1}' \ + --json + +data-agent-cli tools call get_tables \ + --input '{"datasource_id":1,"domains":["sales"]}' \ + --json + +data-agent-cli tools call get_table_schema \ + --input '{"datasource_id":1,"table_name":"orders"}' \ + --json + +data-agent-cli tools call execute_sql \ + --input '{"datasource_id":1,"sql":"SELECT region, SUM(amount) FROM orders GROUP BY region"}' \ + --json +~~~ +`; diff --git a/data-agent-cli/src/trace/store.ts b/data-agent-cli/src/trace/store.ts new file mode 100644 index 00000000..c5640462 --- /dev/null +++ b/data-agent-cli/src/trace/store.ts @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { randomBytes } from 'node:crypto'; +import { chmod, mkdir, readFile, rename, writeFile } from 'node:fs/promises'; +import { dirname } from 'node:path'; +import { defaultConfigDir, stateFilePath } from '../config/store.js'; + +export const DEFAULT_SESSION_KEY = '__default__'; +export const TRACE_IDLE_MS = 30 * 60 * 1000; + +const TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/i; + +export interface TraceResult { + traceparent: string; + traceId: string; +} + +interface TraceEntry { + traceId: string; + lastUsedAt: string; +} + +interface TraceState { + traces: Record; +} + +export async function nextTrace( + sessionKey = DEFAULT_SESSION_KEY, + dir = defaultConfigDir(), + now = Date.now(), +): Promise { + const incoming = process.env.TRACEPARENT; + const incomingMatch = incoming?.match(TRACEPARENT_PATTERN); + if (incomingMatch && !/^0+$/.test(incomingMatch[1])) { + return { traceparent: incomingMatch[0], traceId: incomingMatch[1].toLowerCase() }; + } + + const state = await loadTraceState(dir); + const previous = state.traces[sessionKey]; + const previousTime = previous ? Date.parse(previous.lastUsedAt) : Number.NaN; + const traceId = + previous && Number.isFinite(previousTime) && now - previousTime <= TRACE_IDLE_MS + ? previous.traceId + : randomHex(16); + + state.traces[sessionKey] = { + traceId, + lastUsedAt: new Date(now).toISOString(), + }; + await saveTraceState(state, dir); + + const spanId = randomHex(8); + return { traceparent: `00-${traceId}-${spanId}-01`, traceId }; +} + +async function loadTraceState(dir: string): Promise { + try { + const parsed = JSON.parse(await readFile(stateFilePath(dir), 'utf8')) as unknown; + if (isRecord(parsed) && isRecord(parsed.traces)) { + return { traces: parsed.traces as Record }; + } + } catch { + // 状态文件缺失或损坏时从空状态开始,不阻塞 CLI。 + } + return { traces: {} }; +} + +async function saveTraceState(state: TraceState, dir: string): Promise { + const path = stateFilePath(dir); + await mkdir(dirname(path), { recursive: true, mode: 0o700 }); + const temporary = `${path}.${process.pid}.tmp`; + await writeFile(temporary, JSON.stringify(state, null, 2) + '\n', { mode: 0o600 }); + await rename(temporary, path); + try { + await chmod(path, 0o600); + } catch { + // Windows 上 chmod 可能不支持。 + } +} + +function randomHex(bytes: number): string { + return randomBytes(bytes).toString('hex'); +} + +function isRecord(value: unknown): value is Record { + return typeof value === 'object' && value !== null && !Array.isArray(value); +} diff --git a/data-agent-cli/src/version.ts b/data-agent-cli/src/version.ts new file mode 100644 index 00000000..5ec07f4f --- /dev/null +++ b/data-agent-cli/src/version.ts @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { readFileSync } from 'node:fs'; + +interface Contributor { + name: string; + url?: string; +} + +interface PackageMetadata { + version: string; + author?: Contributor; + contributors?: Contributor[]; +} + +const packageJson = JSON.parse( + readFileSync(new URL('../package.json', import.meta.url), 'utf8'), +) as PackageMetadata; + +export const VERSION = packageJson.version; +export const AUTHOR = packageJson.author; +export const CONTRIBUTORS = packageJson.contributors ?? []; diff --git a/data-agent-cli/test/client.test.ts b/data-agent-cli/test/client.test.ts new file mode 100644 index 00000000..2f595b60 --- /dev/null +++ b/data-agent-cli/test/client.test.ts @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http'; +import type { AddressInfo } from 'node:net'; +import { afterAll, beforeAll, describe, expect, it } from 'vitest'; +import { DataAgentClient } from '../src/client/DataAgentClient.js'; +import { CliError, ExitCode } from '../src/errors.js'; + +const TRACEPARENT = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'; + +let server: Server; +let client: DataAgentClient; + +beforeAll(async () => { + server = createServer((request, response) => handle(request, response)); + await new Promise(resolve => server.listen(0, '127.0.0.1', resolve)); + const address = server.address() as AddressInfo; + client = new DataAgentClient({ + baseUrl: `http://127.0.0.1:${address.port}`, + token: 'pat_test', + timeoutMs: 5_000, + version: '0.0.0-test', + sessionId: 'run-123', + traceProvider: async () => ({ traceparent: TRACEPARENT, traceId: 'trace' }), + }); +}); + +afterAll(async () => { + await new Promise((resolve, reject) => { + server.close(error => (error ? reject(error) : resolve())); + }); +}); + +describe('DataAgentClient', () => { + it('calls health with auth and trace headers', async () => { + const result = await client.health(); + expect(result.name).toBe('test-token'); + }); + + it('lists tools', async () => { + const result = await client.listTools(); + expect(result).toHaveLength(1); + expect(result[0].name).toBe('get_domains'); + }); + + it('calls a tool with session and JSON body and returns the tool result', async () => { + const result = await client.callTool('get_domains', { datasource_id: 1 }); + expect(result.text).toBe('ok'); + expect(result.metadata.returnedRows).toBe(0); + }); + + it('maps 401 responses to auth errors', async () => { + const error = await client.callTool('unauthorized', {}).catch(value => value); + expect(error).toBeInstanceOf(CliError); + expect((error as CliError).exitCode).toBe(ExitCode.Auth); + expect((error as CliError).errorCode).toBe('UNAUTHORIZED'); + }); +}); + +async function handle(request: IncomingMessage, response: ServerResponse): Promise { + const url = request.url ?? '/'; + expect(request.headers.authorization).toBe('Bearer pat_test'); + expect(request.headers.traceparent).toBe(TRACEPARENT); + + if (url === '/agent/health') { + return json(response, 200, { + code: 200, + errorCode: null, + message: 'success', + data: { + id: 1, + name: 'test-token', + tokenPrefix: 'pat_test', + expiresAt: '2026-12-31T23:59:59', + lastUsedAt: null, + revokedAt: null, + createTime: '2026-11-10T10:00:00', + }, + }); + } + + if (url === '/agent/tools') { + return json(response, 200, { + code: 200, + errorCode: null, + message: 'success', + data: [ + { + name: 'get_domains', + description: 'Get domains', + parameters: { type: 'object', properties: {} }, + }, + ], + }); + } + + if (url === '/agent/tools/get_domains') { + expect(request.headers['x-session-id']).toBe('run-123'); + expect(await readBody(request)).toEqual({ datasource_id: 1 }); + return json(response, 200, { + code: 200, + errorCode: null, + message: 'success', + data: { + text: 'ok', + metadata: { returnedRows: 0 }, + traceId: 'trace', + }, + }); + } + + if (url === '/agent/tools/unauthorized') { + return json(response, 401, { + code: 401, + errorCode: 'UNAUTHORIZED', + message: 'Authentication is required.', + data: null, + }); + } + + json(response, 404, { code: 404, errorCode: 'NOT_FOUND', message: 'not found', data: null }); +} + +function json(response: ServerResponse, status: number, body: unknown): void { + response.writeHead(status, { 'Content-Type': 'application/json' }); + response.end(JSON.stringify(body)); +} + +async function readBody(request: IncomingMessage): Promise { + const chunks: Buffer[] = []; + for await (const chunk of request) { + chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)); + } + return JSON.parse(Buffer.concat(chunks).toString('utf8')); +} diff --git a/data-agent-cli/test/config.test.ts b/data-agent-cli/test/config.test.ts new file mode 100644 index 00000000..144e3428 --- /dev/null +++ b/data-agent-cli/test/config.test.ts @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { mkdtemp, readFile, rm } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { afterEach, describe, expect, it } from 'vitest'; +import { + DEFAULT_BASE_URL, + DEFAULT_TIMEOUT_SECONDS, + loadConfig, + resolveBaseUrl, + resolveTimeoutSeconds, + resolveToken, + saveConfig, +} from '../src/config/store.js'; + +const tempDirs: string[] = []; +const originalToken = process.env.DATAAGENT_TOKEN; +const originalBaseUrl = process.env.DATAAGENT_BASE_URL; + +async function tempDir(): Promise { + const dir = await mkdtemp(join(tmpdir(), 'data-agent-cli-config-')); + tempDirs.push(dir); + return dir; +} + +afterEach(async () => { + process.env.DATAAGENT_TOKEN = originalToken; + process.env.DATAAGENT_BASE_URL = originalBaseUrl; + await Promise.all(tempDirs.splice(0).map(dir => rm(dir, { recursive: true, force: true }))); +}); + +describe('config store', () => { + it('uses defaults when config does not exist', async () => { + const config = await loadConfig(await tempDir()); + expect(config.baseUrl).toBe(DEFAULT_BASE_URL); + expect(config.token).toBeUndefined(); + expect(config.timeoutSeconds).toBeUndefined(); + }); + + it('persists config with restricted permissions', async () => { + const dir = await tempDir(); + await saveConfig({ baseUrl: 'http://example.com', token: 'pat_123', timeoutSeconds: 30 }, dir); + + const config = await loadConfig(dir); + expect(config).toEqual({ + baseUrl: 'http://example.com', + token: 'pat_123', + timeoutSeconds: 30, + }); + const body = await readFile(join(dir, 'config.json'), 'utf8'); + expect(body).toContain('"token": "pat_123"'); + }); + + it('resolves token as --token > config > env', async () => { + process.env.DATAAGENT_TOKEN = 'env-token'; + const config = { baseUrl: DEFAULT_BASE_URL, token: 'config-token' }; + expect(resolveToken({}, config)).toBe('config-token'); + expect(resolveToken({ token: 'flag-token' }, config)).toBe('flag-token'); + expect(resolveToken({}, { baseUrl: DEFAULT_BASE_URL })).toBe('env-token'); + }); + + it('resolves base URL and timeout with documented precedence', async () => { + process.env.DATAAGENT_BASE_URL = 'http://env.example.com'; + const config = { baseUrl: 'http://config.example.com' }; + expect(resolveBaseUrl({}, config)).toBe('http://config.example.com'); + expect(resolveBaseUrl({ baseUrl: 'http://flag.example.com' }, config)).toBe( + 'http://flag.example.com', + ); + expect(resolveTimeoutSeconds({}, config)).toBe(DEFAULT_TIMEOUT_SECONDS); + expect(resolveTimeoutSeconds({ timeout: '15' }, config)).toBe(15); + expect(resolveTimeoutSeconds({}, { ...config, timeoutSeconds: 45 })).toBe(45); + }); +}); diff --git a/data-agent-cli/test/input.test.ts b/data-agent-cli/test/input.test.ts new file mode 100644 index 00000000..396de5e5 --- /dev/null +++ b/data-agent-cli/test/input.test.ts @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { mkdtemp, rm, writeFile } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { afterEach, describe, expect, it } from 'vitest'; +import { CliError } from '../src/errors.js'; +import { parseInputText, readInput } from '../src/input.js'; + +const tempDirs: string[] = []; + +async function tempDir(): Promise { + const dir = await mkdtemp(join(tmpdir(), 'data-agent-cli-input-')); + tempDirs.push(dir); + return dir; +} + +afterEach(async () => { + await Promise.all(tempDirs.splice(0).map(dir => rm(dir, { recursive: true, force: true }))); +}); + +describe('input parsing', () => { + it('parses inline JSON objects', () => { + expect(parseInputText('{"datasource_id":1}', '--input')).toEqual({ datasource_id: 1 }); + }); + + it('rejects arrays, null and invalid JSON', () => { + expect(() => parseInputText('[]', '--input')).toThrow(CliError); + expect(() => parseInputText('null', '--input')).toThrow(CliError); + expect(() => parseInputText('{', '--input')).toThrow(CliError); + }); + + it('reads @file input', async () => { + const dir = await tempDir(); + const file = join(dir, 'input.json'); + await writeFile(file, '{"datasource_id":2}', 'utf8'); + await expect(readInput(`@${file}`)).resolves.toEqual({ datasource_id: 2 }); + }); +}); diff --git a/data-agent-cli/test/skill.test.ts b/data-agent-cli/test/skill.test.ts new file mode 100644 index 00000000..9c826401 --- /dev/null +++ b/data-agent-cli/test/skill.test.ts @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { describe, expect, it } from 'vitest'; +import { DATA_QUERY_SKILL } from '../src/skill/data-query.js'; + +describe('data query skill', () => { + it('contains the required workflow and no token', () => { + expect(DATA_QUERY_SKILL).toContain('# DataAgent 问数指南'); + expect(DATA_QUERY_SKILL).toContain('data-agent-cli auth status'); + expect(DATA_QUERY_SKILL).toContain('data-agent-cli tools list'); + expect(DATA_QUERY_SKILL).toContain('data-agent-cli tools call execute_sql'); + expect(DATA_QUERY_SKILL).toContain('session_id'); + expect(DATA_QUERY_SKILL).not.toContain('pat_'); + }); +}); diff --git a/data-agent-cli/test/trace.test.ts b/data-agent-cli/test/trace.test.ts new file mode 100644 index 00000000..3d647c4a --- /dev/null +++ b/data-agent-cli/test/trace.test.ts @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { mkdtemp, rm } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { afterEach, describe, expect, it } from 'vitest'; +import { nextTrace, TRACE_IDLE_MS } from '../src/trace/store.js'; + +const tempDirs: string[] = []; +const originalTraceparent = process.env.TRACEPARENT; + +async function tempDir(): Promise { + const dir = await mkdtemp(join(tmpdir(), 'data-agent-cli-trace-')); + tempDirs.push(dir); + return dir; +} + +afterEach(async () => { + process.env.TRACEPARENT = originalTraceparent; + await Promise.all(tempDirs.splice(0).map(dir => rm(dir, { recursive: true, force: true }))); +}); + +describe('trace store', () => { + it('reuses trace id within the idle window and rotates after it', async () => { + const dir = await tempDir(); + const now = Date.parse('2026-11-10T10:00:00Z'); + const first = await nextTrace('run-1', dir, now); + const second = await nextTrace('run-1', dir, now + 60_000); + const third = await nextTrace('run-1', dir, now + 60_000 + TRACE_IDLE_MS + 1); + + expect(second.traceId).toBe(first.traceId); + expect(third.traceId).not.toBe(first.traceId); + expect(first.traceparent).toMatch(/^00-[0-9a-f]{32}-[0-9a-f]{16}-01$/); + }); + + it('passes through a valid external TRACEPARENT', async () => { + process.env.TRACEPARENT = '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01'; + const result = await nextTrace('run-2', await tempDir()); + expect(result).toEqual({ + traceparent: process.env.TRACEPARENT, + traceId: '4bf92f3577b34da6a3ce929d0e0e4736', + }); + }); +}); diff --git a/data-agent-cli/tsconfig.json b/data-agent-cli/tsconfig.json new file mode 100644 index 00000000..0e6ebeec --- /dev/null +++ b/data-agent-cli/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "lib": ["ES2022"], + "outDir": "dist", + "rootDir": "src", + "strict": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "sourceMap": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"], + "exclude": ["dist", "node_modules", "test"] +} diff --git a/data-agent-frontend/src/api/pat.ts b/data-agent-frontend/src/api/pat.ts new file mode 100644 index 00000000..2de23cfd --- /dev/null +++ b/data-agent-frontend/src/api/pat.ts @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2026 github.com/MaloneTalk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import request from './request'; +import type { ApiResponse } from './request'; +import type { BooleanVo } from './types'; + +export interface UserPat { + id: number; + name: string; + tokenPrefix: string; + expiresAt: string; + lastUsedAt: string | null; + revokedAt: string | null; + createTime: string; +} + +export interface UserPatCreated { + pat: UserPat; + token: string; +} + +export interface CreateUserPatRequest { + name: string; + expiresAt: string; +} + +export function createUserPat(payload: CreateUserPatRequest) { + return request + .post>('/auth/pats', payload) + .then(res => res.data.data); +} + +export function getUserPats() { + return request.get>('/auth/pats').then(res => res.data.data); +} + +export function revokeUserPat(id: number) { + return request + .delete>(`/auth/pats/${id}`) + .then(res => res.data.data.value); +} diff --git a/data-agent-frontend/src/components/layout/AppHeader.vue b/data-agent-frontend/src/components/layout/AppHeader.vue index b95206c8..951c0de6 100644 --- a/data-agent-frontend/src/components/layout/AppHeader.vue +++ b/data-agent-frontend/src/components/layout/AppHeader.vue @@ -33,6 +33,10 @@ userStore.logout(); router.push('/login'); } + + function onOpenTokens() { + router.push('/settings/tokens'); + }