@code-inspector/core
Advanced tools
| import type { CodexOptions } from '../shared'; | ||
| import type { AIContext, AIMessage } from './ai'; | ||
| import type { ProviderCallbacks, ProviderResult } from './ai-provider-claude'; | ||
| /** | ||
| * 获取模型信息 | ||
| * 优先使用用户配置(Codex 暂不通过额外请求探测模型) | ||
| */ | ||
| export declare function getModelInfo(codexOptions: CodexOptions | undefined): Promise<string>; | ||
| /** | ||
| * Codex provider 统一入口 | ||
| */ | ||
| export declare function handleCodexRequest(message: string, context: AIContext | null, history: AIMessage[], sessionId: string | undefined, cwd: string, codexOptions: CodexOptions | undefined, callbacks: ProviderCallbacks): ProviderResult; |
+3
-2
| { | ||
| "name": "@code-inspector/core", | ||
| "version": "2.0.0-beta.5", | ||
| "version": "2.0.0-beta.6", | ||
| "main": "dist/index.js", | ||
@@ -67,3 +67,4 @@ "module": "./dist/index.mjs", | ||
| "optionalDependencies": { | ||
| "@anthropic-ai/claude-agent-sdk": "^0.2.29" | ||
| "@anthropic-ai/claude-agent-sdk": "^0.2.29", | ||
| "@openai/codex-sdk": "^0.106.0" | ||
| }, | ||
@@ -70,0 +71,0 @@ "scripts": { |
@@ -98,3 +98,3 @@ /** | ||
| onToolStart: (toolId: string, toolName: string, index: number) => void; | ||
| onToolInput: (index: number, input: Record<string, any>) => void; | ||
| onToolInput: (index: number, input: Record<string, any>, toolUseId?: string) => void; | ||
| onToolResult: (toolUseId: string, content: string, isError?: boolean) => void; | ||
@@ -101,0 +101,0 @@ onError: (error: Error) => void; |
@@ -1,2 +0,2 @@ | ||
| import type { AIOptions } from '../shared'; | ||
| import type { ClaudeCodeOptions } from '../shared'; | ||
| import type { AIContext, AIMessage } from './ai'; | ||
@@ -14,3 +14,3 @@ export interface ProviderCallbacks { | ||
| */ | ||
| export declare function getModelInfo(aiOptions: AIOptions | undefined): Promise<string>; | ||
| export declare function getModelInfo(aiOptions: ClaudeCodeOptions | undefined): Promise<string>; | ||
| /** | ||
@@ -20,2 +20,2 @@ * Claude provider 统一入口 | ||
| */ | ||
| export declare function handleClaudeRequest(message: string, context: AIContext | null, history: AIMessage[], sessionId: string | undefined, cwd: string, aiOptions: AIOptions | undefined, callbacks: ProviderCallbacks): ProviderResult; | ||
| export declare function handleClaudeRequest(message: string, context: AIContext | null, history: AIMessage[], sessionId: string | undefined, cwd: string, aiOptions: ClaudeCodeOptions | undefined, callbacks: ProviderCallbacks): ProviderResult; |
+15
-6
@@ -7,3 +7,3 @@ /// <reference types="node" /> | ||
| import http from 'http'; | ||
| import type { AIOptions } from '../shared'; | ||
| import type { ClaudeCodeOptions, CodexOptions } from '../shared'; | ||
| /** | ||
@@ -30,6 +30,14 @@ * AI 上下文信息 | ||
| message: string; | ||
| context: AIContext; | ||
| context: AIContext | null; | ||
| history: AIMessage[]; | ||
| sessionId?: string; | ||
| } | ||
| export type AIProviderType = 'claudeCode' | 'codex'; | ||
| export type ActiveAIOptions = { | ||
| provider: 'claudeCode'; | ||
| options: ClaudeCodeOptions; | ||
| } | { | ||
| provider: 'codex'; | ||
| options: CodexOptions; | ||
| }; | ||
| /** | ||
@@ -40,12 +48,13 @@ * 从 behavior 配置中提取 AI 选项 | ||
| ai?: { | ||
| claudeCode?: boolean | AIOptions; | ||
| claudeCode?: boolean | ClaudeCodeOptions; | ||
| codex?: boolean | CodexOptions; | ||
| }; | ||
| }): AIOptions | undefined; | ||
| }): ActiveAIOptions | undefined; | ||
| /** | ||
| * 处理 AI 请求 | ||
| */ | ||
| export declare function handleAIRequest(req: http.IncomingMessage, res: http.ServerResponse, corsHeaders: Record<string, string>, aiOptions: AIOptions | undefined, projectRootPath: string): Promise<void>; | ||
| export declare function handleAIRequest(req: http.IncomingMessage, res: http.ServerResponse, corsHeaders: Record<string, string>, aiOptions: ActiveAIOptions | undefined, projectRootPath: string): Promise<void>; | ||
| /** | ||
| * 处理 AI 模型信息请求 | ||
| */ | ||
| export declare function handleAIModelRequest(res: http.ServerResponse, corsHeaders: Record<string, string>, aiOptions: AIOptions | undefined): Promise<void>; | ||
| export declare function handleAIModelRequest(res: http.ServerResponse, corsHeaders: Record<string, string>, aiOptions: ActiveAIOptions | undefined): Promise<void>; |
+192
-37
@@ -5,45 +5,199 @@ /// <reference types="node" /> | ||
| export type HotKey = 'ctrlKey' | 'altKey' | 'metaKey' | 'shiftKey'; | ||
| export type AIOptions = { | ||
| /** | ||
| * @zh Claude Code CLI 配置项 | ||
| * @en Claude Code CLI options | ||
| */ | ||
| export type ClaudeCliOptions = { | ||
| /** 允许自动执行的工具列表 */ | ||
| allowedTools?: string[]; | ||
| /** 禁止的工具列表 */ | ||
| disallowedTools?: string[]; | ||
| /** 使用的模型 */ | ||
| model?: string; | ||
| /** 最大执行轮数,默认为 20 */ | ||
| maxTurns?: number; | ||
| /** | ||
| * @zh 指定使用的 Agent 类型。'cli' 使用本地 Claude Code CLI,'sdk' 使用 Claude Agent SDK。默认为 'cli' | ||
| * @en Specify the agent type to use. 'cli' uses local Claude Code CLI, 'sdk' uses Claude Agent SDK. Defaults to 'cli' | ||
| * 权限模式。默认为 'bypassPermissions' | ||
| * - 'default' 需要用户确认 | ||
| * - 'acceptEdits' 自动接受编辑 | ||
| * - 'bypassPermissions' 绕过所有权限检查 | ||
| */ | ||
| agent?: 'cli' | 'sdk'; | ||
| permissionMode?: 'default' | 'acceptEdits' | 'bypassPermissions'; | ||
| /** 系统提示 */ | ||
| systemPrompt?: string | { | ||
| type: 'preset'; | ||
| preset: 'claude_code'; | ||
| append?: string; | ||
| }; | ||
| /** 环境变量,传递给 Claude Code 进程。默认为 process.env */ | ||
| env?: Record<string, string | undefined>; | ||
| /** MCP 服务器配置 */ | ||
| mcpServers?: Record<string, any>; | ||
| /** CLI 最大成本(美元),等价于 `--max-cost` */ | ||
| maxCost?: number; | ||
| }; | ||
| /** | ||
| * @zh Claude Code SDK 配置项 | ||
| * @en Claude Code SDK options | ||
| */ | ||
| export type ClaudeSdkOptions = { | ||
| /** 允许自动执行的工具列表 */ | ||
| allowedTools?: string[]; | ||
| /** 禁止的工具列表 */ | ||
| disallowedTools?: string[]; | ||
| /** 使用的模型 */ | ||
| model?: string; | ||
| /** 最大执行轮数,默认为 20 */ | ||
| maxTurns?: number; | ||
| /** | ||
| * @zh SDK 选项,参数格式继承 @anthropic-ai/claude-agent-sdk 官方 SDK 的 Options 类型 | ||
| * @en SDK options, parameter format follows the official @anthropic-ai/claude-agent-sdk Options type | ||
| * @see https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk | ||
| * 权限模式。默认为 'bypassPermissions' | ||
| * - 'default' 需要用户确认 | ||
| * - 'acceptEdits' 自动接受编辑 | ||
| * - 'bypassPermissions' 绕过所有权限检查 | ||
| */ | ||
| sdkOptions?: { | ||
| /** 允许自动执行的工具列表 */ | ||
| allowedTools?: string[]; | ||
| /** 禁止的工具列表 */ | ||
| disallowedTools?: string[]; | ||
| /** 使用的模型 */ | ||
| model?: string; | ||
| /** 最大执行轮数,默认为 20 */ | ||
| maxTurns?: number; | ||
| /** | ||
| * 权限模式。默认为 'bypassPermissions' | ||
| * - 'default' 需要用户确认 | ||
| * - 'acceptEdits' 自动接受编辑 | ||
| * - 'bypassPermissions' 绕过所有权限检查 | ||
| */ | ||
| permissionMode?: 'default' | 'acceptEdits' | 'bypassPermissions'; | ||
| /** 系统提示 */ | ||
| systemPrompt?: string | { | ||
| type: 'preset'; | ||
| preset: 'claude_code'; | ||
| append?: string; | ||
| permissionMode?: 'default' | 'acceptEdits' | 'bypassPermissions'; | ||
| /** 系统提示 */ | ||
| systemPrompt?: string | { | ||
| type: 'preset'; | ||
| preset: 'claude_code'; | ||
| append?: string; | ||
| }; | ||
| /** 环境变量,传递给 Claude Code 进程。默认为 process.env */ | ||
| env?: Record<string, string | undefined>; | ||
| /** MCP 服务器配置 */ | ||
| mcpServers?: Record<string, any>; | ||
| /** 最大思考 token 数 */ | ||
| maxThinkingTokens?: number; | ||
| /** SDK 最大预算(美元) */ | ||
| maxBudgetUsd?: number; | ||
| /** 当 permissionMode='bypassPermissions' 时需要显式开启 */ | ||
| allowDangerouslySkipPermissions?: boolean; | ||
| /** 控制读取哪些 settings 文件。默认读取 user/project/local */ | ||
| settingSources?: Array<'user' | 'project' | 'local'>; | ||
| /** 透传给 Claude CLI 的额外参数(key 不带 --,null 表示布尔 flag) */ | ||
| extraArgs?: Record<string, string | null>; | ||
| }; | ||
| export type ClaudeAgentOptions = ClaudeCliOptions | ClaudeSdkOptions; | ||
| export type ClaudeCodeOptions = { | ||
| /** | ||
| * @zh 指定使用的 Agent 类型。'cli' 使用本地 Claude Code CLI。默认为 'cli' | ||
| * @en Specify the agent type to use. 'cli' uses local Claude Code CLI. Defaults to 'cli' | ||
| */ | ||
| agent?: 'cli'; | ||
| /** | ||
| * @zh CLI 模式参数 | ||
| * @en CLI options | ||
| */ | ||
| options?: ClaudeCliOptions; | ||
| } | { | ||
| /** | ||
| * @zh 指定使用的 Agent 类型。'sdk' 使用 Claude Agent SDK | ||
| * @en Specify the agent type to use. 'sdk' uses Claude Agent SDK | ||
| */ | ||
| agent: 'sdk'; | ||
| /** | ||
| * @zh SDK 模式参数 | ||
| * @en SDK options | ||
| */ | ||
| options?: ClaudeSdkOptions; | ||
| }; | ||
| /** | ||
| * @zh Codex CLI 配置项 | ||
| * @en Codex CLI options | ||
| */ | ||
| export type CodexCliOptions = { | ||
| /** 指定 Codex 模型,等价于 `codex exec -m` */ | ||
| model?: string; | ||
| /** 指定 Codex profile,等价于 `codex exec -p` */ | ||
| profile?: string; | ||
| /** 指定 sandbox 模式,等价于 `codex exec -s` */ | ||
| sandbox?: 'read-only' | 'workspace-write' | 'danger-full-access'; | ||
| /** 是否启用 `--full-auto` */ | ||
| fullAuto?: boolean; | ||
| /** 是否启用 `--skip-git-repo-check` */ | ||
| skipGitRepoCheck?: boolean; | ||
| /** 是否启用 `--ephemeral` */ | ||
| ephemeral?: boolean; | ||
| /** 通过 `-c key=value` 透传给 codex cli 的配置 */ | ||
| config?: Record<string, string | number | boolean>; | ||
| /** 环境变量,传递给 Codex CLI 进程 */ | ||
| env?: Record<string, string | undefined>; | ||
| }; | ||
| /** | ||
| * @zh Codex SDK 配置项 | ||
| * @en Codex SDK options | ||
| */ | ||
| export type CodexSdkOptions = { | ||
| /** 指定 Codex 模型 */ | ||
| model?: string; | ||
| /** 指定 Codex profile */ | ||
| profile?: string; | ||
| /** 透传 Codex 配置 */ | ||
| config?: Record<string, string | number | boolean>; | ||
| /** 环境变量 */ | ||
| env?: Record<string, string | undefined>; | ||
| /** 是否跳过 git 仓库检查 */ | ||
| skipGitRepoCheck?: boolean; | ||
| /** Codex SDK 可执行路径覆盖,等价于 `new Codex({ codexPathOverride })` */ | ||
| codexPathOverride?: string; | ||
| /** Codex SDK baseUrl,等价于 `new Codex({ baseUrl })` */ | ||
| baseUrl?: string; | ||
| /** Codex SDK apiKey,等价于 `new Codex({ apiKey })` */ | ||
| apiKey?: string; | ||
| /** SDK 线程沙箱模式,等价于 `startThread({ sandboxMode })` */ | ||
| sandboxMode?: 'read-only' | 'workspace-write' | 'danger-full-access' | { | ||
| type: 'workspace-write'; | ||
| writableRoots: string[]; | ||
| networkAccess?: boolean; | ||
| excludeTmpdirEnvVar?: boolean; | ||
| } | { | ||
| type: 'danger-full-access'; | ||
| networkAccess?: boolean; | ||
| excludeTmpdirEnvVar?: boolean; | ||
| }; | ||
| /** SDK 线程工作目录(cwd),默认使用当前项目根目录 */ | ||
| cwd?: string; | ||
| /** SDK 推理强度 */ | ||
| modelReasoningEffort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'; | ||
| /** SDK web 搜索请求参数 */ | ||
| webSearchRequest?: { | ||
| searchContextSize?: 'low' | 'medium' | 'high'; | ||
| userLocation?: { | ||
| country?: string; | ||
| region?: string; | ||
| city?: string; | ||
| timezone?: string; | ||
| }; | ||
| /** 环境变量,传递给 Claude Code 进程。默认为 process.env */ | ||
| env?: Record<string, string | undefined>; | ||
| /** MCP 服务器配置 */ | ||
| mcpServers?: Record<string, any>; | ||
| /** 最大思考 token 数 */ | ||
| maxThinkingTokens?: number; | ||
| /** 最大预算(美元) */ | ||
| maxBudgetUsd?: number; | ||
| }; | ||
| /** SDK 是否启用 web 搜索 */ | ||
| enableWebSearch?: boolean; | ||
| /** SDK 审批策略 */ | ||
| approvalPolicy?: 'on-request' | 'on-failure' | 'never' | 'untrusted'; | ||
| /** SDK 额外可写目录 */ | ||
| additionalWritableRoots?: string[]; | ||
| }; | ||
| export type CodexAgentOptions = CodexCliOptions | CodexSdkOptions; | ||
| export type CodexOptions = { | ||
| /** | ||
| * @zh 指定使用的 Agent 类型。'cli' 使用本地 Codex CLI。默认为 'cli' | ||
| * @en Specify the agent type to use. 'cli' uses local Codex CLI. Defaults to 'cli' | ||
| */ | ||
| agent?: 'cli'; | ||
| /** | ||
| * @zh CLI 模式参数 | ||
| * @en CLI options | ||
| */ | ||
| options?: CodexCliOptions; | ||
| } | { | ||
| /** | ||
| * @zh 指定使用的 Agent 类型。'sdk' 使用 Codex SDK | ||
| * @en Specify the agent type to use. 'sdk' uses Codex SDK | ||
| */ | ||
| agent: 'sdk'; | ||
| /** | ||
| * @zh SDK 模式参数 | ||
| * @en SDK options | ||
| */ | ||
| options?: CodexSdkOptions; | ||
| }; | ||
| export type Behavior = { | ||
@@ -54,3 +208,4 @@ locate?: boolean; | ||
| ai?: { | ||
| claudeCode?: boolean | AIOptions; | ||
| claudeCode?: boolean | ClaudeCodeOptions; | ||
| codex?: boolean | CodexOptions; | ||
| }; | ||
@@ -57,0 +212,0 @@ defaultAction?: 'copy' | 'locate' | 'target' | 'ai'; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
12646253
0.71%28
3.7%4555
4.76%8
14.29%44
2.33%