@alint-js/core 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/agent.d.mts +1 -1
- package/dist/index.d.mts +29 -13
- package/dist/index.mjs +732 -473
- package/dist/structured-output.d.mts +1 -1
- package/dist/structured-output.mjs +9 -2
- package/dist/{types-DQfoxG8J.d.mts → types-CIqhJ96f.d.mts} +38 -4
- package/package.json +8 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as ResolvedModel, v as RuleContext } from "./types-CIqhJ96f.mjs";
|
|
2
2
|
import { GenericSchema, InferOutput } from "valibot";
|
|
3
3
|
import { JsonSchema } from "@valibot/to-json-schema";
|
|
4
4
|
import { Message } from "@xsai/shared-chat";
|
|
@@ -57,8 +57,9 @@ async function generateStructured(options) {
|
|
|
57
57
|
tools: [tool]
|
|
58
58
|
});
|
|
59
59
|
} catch (error) {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const callError = `Tool call failed before validation: ${errorMessageFrom(error) ?? String(error)}`;
|
|
61
|
+
previousError = isRetriableHttpError(error) ? void 0 : callError;
|
|
62
|
+
options.logger?.debug(`${options.operation} attempt ${attempt} failed while calling the model: ${callError}`);
|
|
62
63
|
if (!isRetriableCallError(error) || attempt === maxAttempts) throw error;
|
|
63
64
|
await sleep(retryDelay(attempt));
|
|
64
65
|
continue;
|
|
@@ -89,8 +90,14 @@ function exponentialRetryDelay(attempt) {
|
|
|
89
90
|
}
|
|
90
91
|
function isRetriableCallError(error) {
|
|
91
92
|
if (!(error instanceof Error)) return true;
|
|
93
|
+
if (isRetriableHttpError(error)) return true;
|
|
92
94
|
return error.name === "InvalidToolCallError" || error.name === "InvalidToolInputError" || error.name === "ToolExecutionError";
|
|
93
95
|
}
|
|
96
|
+
function isRetriableHttpError(error) {
|
|
97
|
+
if (!(error instanceof Error)) return false;
|
|
98
|
+
const statusCode = "statusCode" in error && typeof error.statusCode === "number" ? error.statusCode : void 0;
|
|
99
|
+
return statusCode !== void 0 && (statusCode >= 500 || [408, 429].includes(statusCode));
|
|
100
|
+
}
|
|
94
101
|
function normalizeJsonSchemaDefinition(schema) {
|
|
95
102
|
if (typeof schema === "boolean") return schema;
|
|
96
103
|
const normalized = { ...schema };
|
|
@@ -95,6 +95,9 @@ interface AgentUsage {
|
|
|
95
95
|
}
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region src/core/source/types.d.ts
|
|
98
|
+
type ClassTarget = SourceTargetOfKind<'class'>;
|
|
99
|
+
type FileTarget = SourceTargetOfKind<'file'>;
|
|
100
|
+
type FunctionTarget = SourceTargetOfKind<'function'>;
|
|
98
101
|
interface LanguageContext {
|
|
99
102
|
cwd: string;
|
|
100
103
|
languageOptions: Record<string, unknown>;
|
|
@@ -162,6 +165,9 @@ interface SourceTarget {
|
|
|
162
165
|
text: string;
|
|
163
166
|
}
|
|
164
167
|
type SourceTargetKind = 'class' | 'file' | 'fragment' | 'function' | 'symbol' | (string & {});
|
|
168
|
+
type SourceTargetOfKind<Kind extends SourceTargetKind> = Omit<SourceTarget, 'kind'> & {
|
|
169
|
+
kind: Kind;
|
|
170
|
+
};
|
|
165
171
|
interface SourceTargetOrigin {
|
|
166
172
|
physicalPath: string;
|
|
167
173
|
range?: SourceRange;
|
|
@@ -180,6 +186,7 @@ type AlintConfigInput = AlintConfigItem | readonly AlintConfigInput[];
|
|
|
180
186
|
interface AlintConfigItem {
|
|
181
187
|
agent?: AgentAdapter;
|
|
182
188
|
basePath?: string;
|
|
189
|
+
directories?: readonly (readonly string[] | string)[];
|
|
183
190
|
extends?: readonly AlintConfigExtends[];
|
|
184
191
|
files?: readonly (readonly string[] | string)[];
|
|
185
192
|
ignore?: IgnoreConfig;
|
|
@@ -215,6 +222,10 @@ interface DiagnosticLocation {
|
|
|
215
222
|
line: number;
|
|
216
223
|
};
|
|
217
224
|
}
|
|
225
|
+
interface DirectoryTarget {
|
|
226
|
+
kind: 'directory';
|
|
227
|
+
path: string;
|
|
228
|
+
}
|
|
218
229
|
interface EnabledRule {
|
|
219
230
|
id: string;
|
|
220
231
|
localId: string;
|
|
@@ -239,6 +250,12 @@ interface ProcessorDefinition {
|
|
|
239
250
|
postprocess?: (diagnostics: DiagnosticDescriptor[], context: ProcessorPostprocessContext) => Awaitable<DiagnosticDescriptor[]>;
|
|
240
251
|
preprocess: (file: SourceFile, context: ProcessorContext) => Awaitable<ProcessedSource[]>;
|
|
241
252
|
}
|
|
253
|
+
interface ProjectTarget {
|
|
254
|
+
files: SourceFile[];
|
|
255
|
+
kind: 'project';
|
|
256
|
+
root: string;
|
|
257
|
+
targets: SourceTarget[];
|
|
258
|
+
}
|
|
242
259
|
type RuleCacheConfig = boolean | {
|
|
243
260
|
level?: 'target';
|
|
244
261
|
};
|
|
@@ -262,12 +279,12 @@ interface RuleContext {
|
|
|
262
279
|
}
|
|
263
280
|
interface RuleDefinition {
|
|
264
281
|
cache?: RuleCacheConfig;
|
|
282
|
+
/** Additional stable rule inputs, such as imported prompts, that invalidate cached results when changed. */
|
|
283
|
+
cacheKey?: unknown;
|
|
265
284
|
create: (context: RuleContext) => RuleHandlers;
|
|
266
285
|
model?: ModelRequirement;
|
|
267
286
|
}
|
|
268
|
-
|
|
269
|
-
onTarget?: (target: SourceTarget) => Awaitable<void>;
|
|
270
|
-
}
|
|
287
|
+
type RuleHandlers = RuleSpecializedHandlers | RuleWithHandler;
|
|
271
288
|
interface RuleInferenceUsageRecord {
|
|
272
289
|
filePath?: string;
|
|
273
290
|
inputTokens?: number;
|
|
@@ -283,5 +300,22 @@ interface RuleRegistry {
|
|
|
283
300
|
rules: Map<string, RuleDefinition>;
|
|
284
301
|
}
|
|
285
302
|
type RuleSeverity = 'error' | 'off' | 'warn';
|
|
303
|
+
interface RuleSpecializedHandlers {
|
|
304
|
+
onTargetClass?: (target: ClassTarget) => Awaitable<void>;
|
|
305
|
+
onTargetDirectory?: (target: DirectoryTarget) => Awaitable<void>;
|
|
306
|
+
onTargetFile?: (target: FileTarget) => Awaitable<void>;
|
|
307
|
+
onTargetFunction?: (target: FunctionTarget) => Awaitable<void>;
|
|
308
|
+
onTargetProject?: (target: ProjectTarget) => Awaitable<void>;
|
|
309
|
+
onTargetWith?: never;
|
|
310
|
+
}
|
|
311
|
+
interface RuleWithHandler {
|
|
312
|
+
onTargetClass?: never;
|
|
313
|
+
onTargetDirectory?: never;
|
|
314
|
+
onTargetFile?: never;
|
|
315
|
+
onTargetFunction?: never;
|
|
316
|
+
onTargetProject?: never;
|
|
317
|
+
onTargetWith: (target: Target) => Awaitable<void>;
|
|
318
|
+
}
|
|
319
|
+
type Target = DirectoryTarget | ProjectTarget | SourceTarget;
|
|
286
320
|
//#endregion
|
|
287
|
-
export {
|
|
321
|
+
export { ResolvedModel as $, LanguageContext as A, SourceRuntime as B, RuleSeverity as C, ClassTarget as D, Target as E, ProcessorPostprocessContext as F, SourceText as G, SourceTargetKind as H, SourceFile as I, AgentResult as J, AgentAdapter as K, SourceLocation as L, ProcessedSource as M, ProcessedSourceOrigin as N, FileTarget as O, ProcessorContext as P, ResolveModelOptions as Q, SourcePosition as R, RuleRegistry as S, RuleWithHandler as T, SourceTargetOfKind as U, SourceTarget as V, SourceTargetOrigin as W, AgentUsage as X, AgentTool as Y, ModelRequirement as Z, RuleConfigEntry as _, AlintLinterOptions as a, RunnerStatsConfig as at, RuleHandlers as b, DiagnosticLocation as c, IgnoreConfig as d, ResolvedProvider as et, LanguageDefinition as f, RuleCacheConfig as g, ProjectTarget as h, AlintConfigItem as i, RunnerConfig as it, LineRange as j, FunctionTarget as k, DirectoryTarget as l, ProcessorDefinition as m, AlintConfigExtends as n, ProviderDefinition as nt, Awaitable as o, SetupConfig as ot, PluginDefinition as p, AgentRequest as q, AlintConfigInput as r, ProviderType as rt, DiagnosticDescriptor as s, SetupModelDefinition as st, AlintConfig as t, ModelSize as tt, EnabledRule as u, RuleContext as v, RuleSpecializedHandlers as w, RuleInferenceUsageRecord as x, RuleDefinition as y, SourceRange as z };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alint-js/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.24",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.mts",
|
|
@@ -23,15 +23,19 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@moeru/std": "^0.1.0-beta.18",
|
|
25
25
|
"@valibot/to-json-schema": "^1.7.1",
|
|
26
|
-
"@xsai/generate-text": "^0.5.0-beta.
|
|
27
|
-
"@xsai/shared-chat": "^0.5.0-beta.
|
|
28
|
-
"@xsai/tool": "^0.5.0-beta.
|
|
26
|
+
"@xsai/generate-text": "^0.5.0-beta.7",
|
|
27
|
+
"@xsai/shared-chat": "^0.5.0-beta.7",
|
|
28
|
+
"@xsai/tool": "^0.5.0-beta.7",
|
|
29
29
|
"es-toolkit": "^1.49.0",
|
|
30
30
|
"minimatch": "^10.2.5",
|
|
31
31
|
"oxc-parser": "^0.137.0",
|
|
32
32
|
"pathe": "^2.0.3",
|
|
33
33
|
"valibot": "^1.4.1"
|
|
34
34
|
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"effect": "^3.22.0",
|
|
37
|
+
"sury": "^10.0.4"
|
|
38
|
+
},
|
|
35
39
|
"scripts": {
|
|
36
40
|
"build": "tsdown",
|
|
37
41
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|