@xioflow/kernel 0.1.0
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/LICENSE +21 -0
- package/README.md +129 -0
- package/dist/domain.d.ts +56 -0
- package/dist/domain.d.ts.map +1 -0
- package/dist/domain.js +322 -0
- package/dist/domain.js.map +1 -0
- package/dist/driver/node-driver.d.ts +29 -0
- package/dist/driver/node-driver.d.ts.map +1 -0
- package/dist/driver/node-driver.js +404 -0
- package/dist/driver/node-driver.js.map +1 -0
- package/dist/driver/types.d.ts +60 -0
- package/dist/driver/types.d.ts.map +1 -0
- package/dist/driver/types.js +2 -0
- package/dist/driver/types.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/recovery/engine.d.ts +19 -0
- package/dist/recovery/engine.d.ts.map +1 -0
- package/dist/recovery/engine.js +129 -0
- package/dist/recovery/engine.js.map +1 -0
- package/dist/store/schema.d.ts +5 -0
- package/dist/store/schema.d.ts.map +1 -0
- package/dist/store/schema.js +78 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store/sqlite.d.ts +53 -0
- package/dist/store/sqlite.d.ts.map +1 -0
- package/dist/store/sqlite.js +466 -0
- package/dist/store/sqlite.js.map +1 -0
- package/dist/supervisor/supervisor.d.ts +36 -0
- package/dist/supervisor/supervisor.d.ts.map +1 -0
- package/dist/supervisor/supervisor.js +421 -0
- package/dist/supervisor/supervisor.js.map +1 -0
- package/dist/testing/contract-suite.d.ts +11 -0
- package/dist/testing/contract-suite.d.ts.map +1 -0
- package/dist/testing/contract-suite.js +582 -0
- package/dist/testing/contract-suite.js.map +1 -0
- package/dist/types.d.ts +190 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +90 -0
- package/dist/types.js.map +1 -0
- package/package.json +68 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xioflow 核心领域模型与实体契约
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 逻辑工作单元
|
|
6
|
+
*/
|
|
7
|
+
export interface Task {
|
|
8
|
+
id: string;
|
|
9
|
+
domainId: string;
|
|
10
|
+
name: string;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
meta?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 单次执行尝试
|
|
16
|
+
*/
|
|
17
|
+
export interface Run {
|
|
18
|
+
id: string;
|
|
19
|
+
taskId: string;
|
|
20
|
+
domainId: string;
|
|
21
|
+
owner: string;
|
|
22
|
+
status: KernelRunStatus;
|
|
23
|
+
terminationReason?: TerminationReason;
|
|
24
|
+
startedAt: string;
|
|
25
|
+
endedAt?: string;
|
|
26
|
+
configSnapshotWhiteList?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
export type KernelRunStatus = 'queued' | 'starting' | 'running' | 'stopping' | 'succeeded' | 'failed' | 'cancelled' | 'indeterminate';
|
|
29
|
+
export type TerminationReason = 'completed' | 'user_cancelled' | 'timed_out' | 'resource_preempted' | 'crash_detected' | 'memory_exceeded' | 'cpu_exceeded' | 'pids_exceeded' | 'output_exceeded';
|
|
30
|
+
/**
|
|
31
|
+
* 资源治理预算契约
|
|
32
|
+
*/
|
|
33
|
+
export interface ResourceBudget {
|
|
34
|
+
maxMemoryBytes?: number;
|
|
35
|
+
maxPids?: number;
|
|
36
|
+
maxCpuTimeMs?: number;
|
|
37
|
+
maxOutputBytes?: number;
|
|
38
|
+
enforcement: 'observe' | 'soft' | 'hard';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 执行域级别配额
|
|
42
|
+
*/
|
|
43
|
+
export interface DomainBudget {
|
|
44
|
+
maxTotalMemoryBytes?: number;
|
|
45
|
+
maxConcurrentOps?: number;
|
|
46
|
+
maxTotalOutputBytes?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 受监督原子操作
|
|
50
|
+
*/
|
|
51
|
+
export interface Operation {
|
|
52
|
+
id: string;
|
|
53
|
+
runId: string;
|
|
54
|
+
kind: 'process' | 'filesystem' | 'gate' | 'custom';
|
|
55
|
+
name: string;
|
|
56
|
+
inputFingerprint: string;
|
|
57
|
+
requiredResources: string[];
|
|
58
|
+
timeoutMs?: number;
|
|
59
|
+
resourceBudget?: ResourceBudget;
|
|
60
|
+
outputRef?: string;
|
|
61
|
+
status: OperationStatus;
|
|
62
|
+
result?: OperationResult;
|
|
63
|
+
processIdentity?: {
|
|
64
|
+
pid: number;
|
|
65
|
+
startTimeMonotonic?: number;
|
|
66
|
+
spawnTime: string;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export type OperationStatus = 'pending' | 'intent_registered' | 'active' | 'stopping' | 'done';
|
|
70
|
+
/**
|
|
71
|
+
* 多态执行结果
|
|
72
|
+
*/
|
|
73
|
+
export type OperationResult = ProcessOperationResult | FilesystemOperationResult | GenericOperationResult | IndeterminateResult;
|
|
74
|
+
export interface BaseResult {
|
|
75
|
+
durationMs: number;
|
|
76
|
+
completedAt: string;
|
|
77
|
+
}
|
|
78
|
+
export interface ProcessOperationResult extends BaseResult {
|
|
79
|
+
kind: 'process';
|
|
80
|
+
status: 'succeeded' | 'failed' | 'cancelled';
|
|
81
|
+
exitCode: number | null;
|
|
82
|
+
signal: NodeJS.Signals | null;
|
|
83
|
+
stdout: string;
|
|
84
|
+
stderr: string;
|
|
85
|
+
isTruncated: boolean;
|
|
86
|
+
stdoutTruncated?: boolean;
|
|
87
|
+
stderrTruncated?: boolean;
|
|
88
|
+
stdoutRef?: string;
|
|
89
|
+
stderrRef?: string;
|
|
90
|
+
stdoutBytes?: number;
|
|
91
|
+
stderrBytes?: number;
|
|
92
|
+
stdoutHash?: string;
|
|
93
|
+
stderrHash?: string;
|
|
94
|
+
outputRef?: string;
|
|
95
|
+
outputHash?: string;
|
|
96
|
+
terminationReason?: TerminationReason;
|
|
97
|
+
peakMemoryBytes?: number;
|
|
98
|
+
cpuTimeMs?: number;
|
|
99
|
+
identityVerification: IdentityVerificationResult;
|
|
100
|
+
}
|
|
101
|
+
export interface FilesystemOperationResult extends BaseResult {
|
|
102
|
+
kind: 'filesystem';
|
|
103
|
+
status: 'succeeded' | 'failed';
|
|
104
|
+
targetPath: string;
|
|
105
|
+
action: 'create' | 'modify' | 'delete';
|
|
106
|
+
bytesWritten?: number;
|
|
107
|
+
outputRef?: string;
|
|
108
|
+
errorMessage?: string;
|
|
109
|
+
}
|
|
110
|
+
export interface GenericOperationResult extends BaseResult {
|
|
111
|
+
kind: 'generic';
|
|
112
|
+
status: 'succeeded' | 'failed' | 'cancelled';
|
|
113
|
+
outputRef?: string;
|
|
114
|
+
errorMessage?: string;
|
|
115
|
+
}
|
|
116
|
+
export interface IndeterminateResult extends BaseResult {
|
|
117
|
+
kind: 'indeterminate';
|
|
118
|
+
status: 'indeterminate';
|
|
119
|
+
reason: string;
|
|
120
|
+
recoveryGuidance: string;
|
|
121
|
+
}
|
|
122
|
+
export type IdentityVerificationResult = 'is_original_process' | 'not_original_process' | 'cannot_determine';
|
|
123
|
+
/**
|
|
124
|
+
* 域所有权记录(用于代际栅栏与防脑裂)
|
|
125
|
+
*/
|
|
126
|
+
export interface OwnerRecord {
|
|
127
|
+
domainId: string;
|
|
128
|
+
ownerId: string;
|
|
129
|
+
epoch: number;
|
|
130
|
+
heartbeatAt: string;
|
|
131
|
+
expiresAt: string;
|
|
132
|
+
hostname: string;
|
|
133
|
+
}
|
|
134
|
+
export declare class UnsupportedCapabilityError extends Error {
|
|
135
|
+
readonly capability: string;
|
|
136
|
+
readonly platform: string;
|
|
137
|
+
readonly requestedEnforcement: string;
|
|
138
|
+
constructor(capability: string, platform: string, requestedEnforcement?: string);
|
|
139
|
+
}
|
|
140
|
+
export declare class EpochFencedError extends Error {
|
|
141
|
+
readonly domainId: string;
|
|
142
|
+
readonly expectedEpoch: number;
|
|
143
|
+
readonly actualEpoch: number;
|
|
144
|
+
constructor(domainId: string, expectedEpoch: number, actualEpoch: number);
|
|
145
|
+
}
|
|
146
|
+
export declare class DomainLockedError extends Error {
|
|
147
|
+
readonly domainId: string;
|
|
148
|
+
readonly ownerPid: number;
|
|
149
|
+
readonly acquiredAt: string;
|
|
150
|
+
constructor(domainId: string, ownerPid: number, acquiredAt: string);
|
|
151
|
+
}
|
|
152
|
+
export declare class ResourceConflictError extends Error {
|
|
153
|
+
readonly resourceId: string;
|
|
154
|
+
readonly existingOwnerOpId: string;
|
|
155
|
+
readonly requestingOpId: string;
|
|
156
|
+
readonly waitedDurationMs: number;
|
|
157
|
+
constructor(resourceId: string, existingOwnerOpId: string, requestingOpId: string, waitedDurationMs?: number);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* 持久化资源占用
|
|
161
|
+
*/
|
|
162
|
+
export interface ResourceLease {
|
|
163
|
+
resourceId: string;
|
|
164
|
+
operationId: string;
|
|
165
|
+
domainId: string;
|
|
166
|
+
acquiredAt: string;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* 单调自增序号事件日志
|
|
170
|
+
*/
|
|
171
|
+
export interface JournalEvent {
|
|
172
|
+
seq: number;
|
|
173
|
+
domainId: string;
|
|
174
|
+
runId?: string;
|
|
175
|
+
operationId?: string;
|
|
176
|
+
type: string;
|
|
177
|
+
payload: Record<string, unknown>;
|
|
178
|
+
timestamp: string;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* 域所有权锁元数据
|
|
182
|
+
*/
|
|
183
|
+
export interface DomainLockMetadata {
|
|
184
|
+
domainId: string;
|
|
185
|
+
ownerPid: number;
|
|
186
|
+
acquiredAt: string;
|
|
187
|
+
hostname: string;
|
|
188
|
+
}
|
|
189
|
+
export declare function sanitizeConfigSnapshot(config?: Record<string, unknown>): Record<string, unknown>;
|
|
190
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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AE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAkBD,wBAAgB,sBAAsB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqBhG"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xioflow 核心领域模型与实体契约
|
|
3
|
+
*/
|
|
4
|
+
export class UnsupportedCapabilityError extends Error {
|
|
5
|
+
capability;
|
|
6
|
+
platform;
|
|
7
|
+
requestedEnforcement;
|
|
8
|
+
constructor(capability, platform, requestedEnforcement = 'hard') {
|
|
9
|
+
super(`Unsupported capability: '${capability}' with enforcement '${requestedEnforcement}' is not supported on platform '${platform}'`);
|
|
10
|
+
this.capability = capability;
|
|
11
|
+
this.platform = platform;
|
|
12
|
+
this.requestedEnforcement = requestedEnforcement;
|
|
13
|
+
this.name = 'UnsupportedCapabilityError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class EpochFencedError extends Error {
|
|
17
|
+
domainId;
|
|
18
|
+
expectedEpoch;
|
|
19
|
+
actualEpoch;
|
|
20
|
+
constructor(domainId, expectedEpoch, actualEpoch) {
|
|
21
|
+
super(`Epoch fenced: write rejected in domain '${domainId}'. Expected epoch ${expectedEpoch}, but current epoch is ${actualEpoch}`);
|
|
22
|
+
this.domainId = domainId;
|
|
23
|
+
this.expectedEpoch = expectedEpoch;
|
|
24
|
+
this.actualEpoch = actualEpoch;
|
|
25
|
+
this.name = 'EpochFencedError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class DomainLockedError extends Error {
|
|
29
|
+
domainId;
|
|
30
|
+
ownerPid;
|
|
31
|
+
acquiredAt;
|
|
32
|
+
constructor(domainId, ownerPid, acquiredAt) {
|
|
33
|
+
super(`Execution domain '${domainId}' is already locked by process ${ownerPid} (acquired at ${acquiredAt})`);
|
|
34
|
+
this.domainId = domainId;
|
|
35
|
+
this.ownerPid = ownerPid;
|
|
36
|
+
this.acquiredAt = acquiredAt;
|
|
37
|
+
this.name = 'DomainLockedError';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export class ResourceConflictError extends Error {
|
|
41
|
+
resourceId;
|
|
42
|
+
existingOwnerOpId;
|
|
43
|
+
requestingOpId;
|
|
44
|
+
waitedDurationMs;
|
|
45
|
+
constructor(resourceId, existingOwnerOpId, requestingOpId, waitedDurationMs = 0) {
|
|
46
|
+
super(`Resource conflict: resource '${resourceId}' is held by operation '${existingOwnerOpId}', requested by '${requestingOpId}' (waited ${waitedDurationMs}ms)`);
|
|
47
|
+
this.resourceId = resourceId;
|
|
48
|
+
this.existingOwnerOpId = existingOwnerOpId;
|
|
49
|
+
this.requestingOpId = requestingOpId;
|
|
50
|
+
this.waitedDurationMs = waitedDurationMs;
|
|
51
|
+
this.name = 'ResourceConflictError';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 白名单安全配置过滤:杜绝密码、密钥等敏感信息落盘
|
|
56
|
+
*/
|
|
57
|
+
const SAFE_CONFIG_WHITELIST = new Set([
|
|
58
|
+
'model',
|
|
59
|
+
'temperature',
|
|
60
|
+
'maxTokens',
|
|
61
|
+
'cwd',
|
|
62
|
+
'timeoutMs',
|
|
63
|
+
'maxRetries',
|
|
64
|
+
'mode',
|
|
65
|
+
'environment',
|
|
66
|
+
'permissionScope',
|
|
67
|
+
'toolsAllowed'
|
|
68
|
+
]);
|
|
69
|
+
export function sanitizeConfigSnapshot(config) {
|
|
70
|
+
if (!config)
|
|
71
|
+
return {};
|
|
72
|
+
const sanitized = {};
|
|
73
|
+
for (const [key, value] of Object.entries(config)) {
|
|
74
|
+
const lowerKey = key.toLowerCase();
|
|
75
|
+
// 过滤包含敏感关键词的字段
|
|
76
|
+
if (lowerKey.includes('token') ||
|
|
77
|
+
lowerKey.includes('key') ||
|
|
78
|
+
lowerKey.includes('secret') ||
|
|
79
|
+
lowerKey.includes('password') ||
|
|
80
|
+
lowerKey.includes('auth') ||
|
|
81
|
+
lowerKey.includes('credential')) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (SAFE_CONFIG_WHITELIST.has(key) || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
85
|
+
sanitized[key] = value;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return sanitized;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiLH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAEjC,UAAU;IACV,QAAQ;IACR,oBAAoB;IAHtC,YACkB,UAAkB,EAClB,QAAgB,EAChB,oBAAoB,GAAW,MAAM;QAErD,KAAK,CACH,4BAA4B,UAAU,uBAAuB,oBAAoB,mCAAmC,QAAQ,GAAG,CAChI,CAAC;0BANc,UAAU;wBACV,QAAQ;oCACR,oBAAoB;QAKpC,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AAEH,MAAM,UAAU,sBAAsB,CAAC,MAAgC;IACrE,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,MAAM,SAAS,GAA4B,EAAE,CAAC;IAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACnC,eAAe;QACf,IACE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;YAC1B,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;YACxB,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAC3B,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC7B,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;YACzB,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,EAC/B,CAAC;YACD,SAAS;QACX,CAAC;QACD,IAAI,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YAC3H,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xioflow/kernel",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Supervised execution kernel for AI agents: intent-first spawn, confirmed stop pipeline, honest crash recovery",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22.5.0"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./testing": {
|
|
18
|
+
"types": "./dist/testing/contract-suite.d.ts",
|
|
19
|
+
"default": "./dist/testing/contract-suite.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/Xio-Shark/xioflow.git"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/Xio-Shark/xioflow#readme",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/Xio-Shark/xioflow/issues"
|
|
39
|
+
},
|
|
40
|
+
"packageManager": "pnpm@10.32.1",
|
|
41
|
+
"keywords": [
|
|
42
|
+
"ai-agent",
|
|
43
|
+
"agent-runtime",
|
|
44
|
+
"process-supervisor",
|
|
45
|
+
"crash-recovery",
|
|
46
|
+
"orchestration"
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc -p tsconfig.build.json",
|
|
50
|
+
"typecheck": "tsc --noEmit",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"verify:package": "node scripts/verify-package.mjs",
|
|
53
|
+
"prepack": "npm run build"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^26.6.1",
|
|
57
|
+
"typescript": "^7.0.2",
|
|
58
|
+
"vitest": "^5.0.1"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"vitest": ">=3"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"vitest": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|