proxylang 0.11.0 → 0.13.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/README.md +116 -374
- package/dist/build-B_eJXR4E.js +3619 -0
- package/dist/cli.js +216 -175
- package/dist/index.d.ts +830 -809
- package/dist/index.js +347 -178
- package/package.json +6 -4
- package/dist/profile-build-BVhtmxFG.js +0 -3901
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
//#region src/
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
7
|
-
|
|
2
|
+
//#region src/model/identity.d.ts
|
|
3
|
+
type Origin = {
|
|
4
|
+
readonly file: string;
|
|
5
|
+
readonly line: number;
|
|
6
|
+
readonly column: number;
|
|
7
|
+
};
|
|
8
|
+
declare const sdkIdentity: unique symbol;
|
|
9
|
+
type SDK<K extends string> = {
|
|
10
|
+
readonly [sdkIdentity]: K;
|
|
8
11
|
};
|
|
9
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/model/types.d.ts
|
|
14
|
+
type Network = "tcp" | "udp";
|
|
15
|
+
type NativeRuleSet = {
|
|
10
16
|
readonly type: "nativeRuleSet";
|
|
11
17
|
readonly id: string;
|
|
12
18
|
readonly url: string;
|
|
@@ -20,13 +26,14 @@ export type NativeRuleSet = {
|
|
|
20
26
|
readonly engine: "sing-box";
|
|
21
27
|
readonly format: "source" | "binary";
|
|
22
28
|
readonly intervalSeconds: number;
|
|
29
|
+
readonly resolve?: boolean;
|
|
23
30
|
} | {
|
|
24
31
|
readonly engine: "mihomo";
|
|
25
32
|
readonly format: "yaml" | "text";
|
|
26
33
|
readonly behavior: "domain" | "ipcidr" | "classical";
|
|
27
34
|
readonly intervalSeconds: number;
|
|
28
35
|
});
|
|
29
|
-
|
|
36
|
+
type Match = NativeRuleSet | {
|
|
30
37
|
readonly type: "domain" | "domainSuffix";
|
|
31
38
|
readonly includeSniffed?: boolean;
|
|
32
39
|
readonly value: string;
|
|
@@ -51,85 +58,49 @@ export type Match = NamedRuleSet | NativeRuleSet | {
|
|
|
51
58
|
readonly type: "not";
|
|
52
59
|
readonly condition: Match;
|
|
53
60
|
};
|
|
54
|
-
|
|
55
|
-
readonly type: "direct" | "reject";
|
|
56
|
-
} | {
|
|
57
|
-
readonly type: "route";
|
|
58
|
-
readonly to: string;
|
|
59
|
-
};
|
|
60
|
-
export type Slot<S extends string = string> = {
|
|
61
|
-
readonly type: "slot";
|
|
62
|
-
readonly name: S;
|
|
63
|
-
};
|
|
64
|
-
export type Rule<S extends string = string> = {
|
|
65
|
-
readonly type: "rule";
|
|
66
|
-
readonly id: string;
|
|
67
|
-
readonly when: Match;
|
|
68
|
-
readonly then: Action | Slot<S>;
|
|
69
|
-
};
|
|
70
|
-
export type Block<S extends string = string> = {
|
|
71
|
-
readonly type: "block";
|
|
72
|
-
readonly id: string;
|
|
73
|
-
readonly rules: readonly Entry<S>[];
|
|
74
|
-
readonly when?: Match;
|
|
75
|
-
};
|
|
76
|
-
export type Policy<S extends string = string> = {
|
|
77
|
-
readonly type: "policy";
|
|
78
|
-
readonly id: string;
|
|
79
|
-
readonly exits: readonly S[];
|
|
80
|
-
readonly rules: readonly Entry[];
|
|
81
|
-
};
|
|
82
|
-
export type Use<S extends string = string> = {
|
|
83
|
-
readonly type: "use";
|
|
84
|
-
readonly id: string;
|
|
85
|
-
readonly policy: Policy;
|
|
86
|
-
readonly bindings: Readonly<Record<string, Action | Slot<S>>>;
|
|
87
|
-
};
|
|
88
|
-
export type Entry<S extends string = string> = Rule<S> | Block<S> | Use<S>;
|
|
89
|
-
export type Secret = {
|
|
61
|
+
type Secret = {
|
|
90
62
|
readonly type: "env";
|
|
91
63
|
readonly name: string;
|
|
92
64
|
};
|
|
93
|
-
|
|
65
|
+
type ProxyBase = {
|
|
94
66
|
readonly id: string;
|
|
95
67
|
readonly server: string;
|
|
96
68
|
readonly port: number;
|
|
97
69
|
readonly via?: string;
|
|
98
70
|
readonly tcpFastOpen?: boolean;
|
|
99
|
-
readonly label?: string;
|
|
100
71
|
};
|
|
101
|
-
|
|
72
|
+
type ProxyTLS = {
|
|
102
73
|
readonly serverName: string;
|
|
103
74
|
readonly alpn?: readonly string[];
|
|
104
75
|
readonly skipCertVerify?: boolean;
|
|
105
76
|
};
|
|
106
|
-
|
|
77
|
+
type SurgeProxyOptions = {
|
|
107
78
|
readonly udpRelay?: boolean;
|
|
108
79
|
readonly blockQuic?: "auto" | "on" | "off";
|
|
109
80
|
};
|
|
110
81
|
type SurgeAutomaticUdpOptions = Omit<SurgeProxyOptions, "udpRelay"> & {
|
|
111
82
|
readonly udpRelay?: true;
|
|
112
83
|
};
|
|
113
|
-
|
|
84
|
+
type WebSocketTransport = {
|
|
114
85
|
readonly type: "ws";
|
|
115
86
|
readonly path: string;
|
|
116
87
|
readonly host?: string;
|
|
117
88
|
};
|
|
118
|
-
|
|
89
|
+
type TrojanNode$1 = ProxyBase & {
|
|
119
90
|
readonly type: "trojan";
|
|
120
91
|
readonly password: Secret;
|
|
121
92
|
readonly serverName?: string;
|
|
122
93
|
readonly skipCertVerify?: boolean;
|
|
123
94
|
readonly surge?: SurgeAutomaticUdpOptions;
|
|
124
95
|
};
|
|
125
|
-
|
|
96
|
+
type AnyTLSNode$1 = ProxyBase & {
|
|
126
97
|
readonly type: "anytls";
|
|
127
98
|
readonly password: Secret;
|
|
128
99
|
readonly serverName?: string;
|
|
129
100
|
readonly skipCertVerify?: boolean;
|
|
130
101
|
readonly surge?: SurgeAutomaticUdpOptions;
|
|
131
102
|
};
|
|
132
|
-
|
|
103
|
+
type Hysteria2Node$1 = Omit<ProxyBase, "tcpFastOpen"> & {
|
|
133
104
|
readonly type: "hysteria2";
|
|
134
105
|
readonly tcpFastOpen?: never;
|
|
135
106
|
readonly password: Secret;
|
|
@@ -138,26 +109,26 @@ export type Hysteria2Node = Omit<ProxyBase, "tcpFastOpen"> & {
|
|
|
138
109
|
readonly portHopping?: string;
|
|
139
110
|
readonly portHoppingInterval?: number;
|
|
140
111
|
};
|
|
141
|
-
|
|
112
|
+
type HttpNode$1 = ProxyBase & {
|
|
142
113
|
readonly type: "http";
|
|
143
114
|
readonly serverName?: never;
|
|
144
115
|
readonly password: Secret;
|
|
145
116
|
readonly username?: Secret;
|
|
146
117
|
};
|
|
147
|
-
|
|
118
|
+
type ShadowsocksNode$1 = ProxyBase & {
|
|
148
119
|
readonly type: "shadowsocks";
|
|
149
120
|
readonly method: "aes-128-gcm" | "aes-256-gcm" | "chacha20-ietf-poly1305";
|
|
150
121
|
readonly password: Secret;
|
|
151
122
|
readonly surge?: SurgeProxyOptions;
|
|
152
123
|
};
|
|
153
|
-
|
|
124
|
+
type VMessNode$1 = ProxyBase & {
|
|
154
125
|
readonly type: "vmess";
|
|
155
126
|
readonly uuid: Secret;
|
|
156
127
|
readonly tls?: ProxyTLS;
|
|
157
128
|
readonly transport?: WebSocketTransport;
|
|
158
129
|
readonly surge?: Pick<SurgeProxyOptions, "blockQuic">;
|
|
159
130
|
};
|
|
160
|
-
|
|
131
|
+
type VLESSNode$1 = ProxyBase & {
|
|
161
132
|
readonly type: "vless";
|
|
162
133
|
readonly uuid: Secret;
|
|
163
134
|
readonly tls?: ProxyTLS;
|
|
@@ -170,8 +141,8 @@ export type VLESSNode = ProxyBase & {
|
|
|
170
141
|
};
|
|
171
142
|
readonly utlsFingerprint?: "chrome";
|
|
172
143
|
};
|
|
173
|
-
|
|
174
|
-
|
|
144
|
+
type ProxyNode$1 = TrojanNode$1 | AnyTLSNode$1 | Hysteria2Node$1 | HttpNode$1 | ShadowsocksNode$1 | VMessNode$1 | VLESSNode$1;
|
|
145
|
+
type TailscaleEndpoint = {
|
|
175
146
|
readonly type: "sing-box-tailscale";
|
|
176
147
|
readonly id: string;
|
|
177
148
|
readonly hostname: string;
|
|
@@ -182,77 +153,23 @@ export type TailscaleEndpoint = {
|
|
|
182
153
|
readonly exitNode?: string;
|
|
183
154
|
readonly exitNodeAllowLanAccess?: boolean;
|
|
184
155
|
};
|
|
185
|
-
|
|
186
|
-
readonly type: "select";
|
|
187
|
-
} | {
|
|
188
|
-
readonly type: "surge-smart";
|
|
189
|
-
} | {
|
|
190
|
-
readonly type: "urltest";
|
|
191
|
-
readonly url: string;
|
|
192
|
-
readonly intervalSeconds?: number;
|
|
193
|
-
readonly toleranceMs?: number;
|
|
194
|
-
};
|
|
195
|
-
export type PortableAlgorithm = {
|
|
156
|
+
type GroupAlgorithm = {
|
|
196
157
|
readonly type: "auto";
|
|
197
|
-
} | Extract<GroupAlgorithm, {
|
|
198
|
-
readonly type: "select" | "urltest";
|
|
199
|
-
}>;
|
|
200
|
-
export type StrategyImplementations = {
|
|
201
|
-
readonly surge?: GroupAlgorithm;
|
|
202
|
-
readonly "sing-box"?: GroupAlgorithm;
|
|
203
|
-
readonly mihomo?: GroupAlgorithm;
|
|
204
|
-
readonly stash?: GroupAlgorithm;
|
|
205
|
-
};
|
|
206
|
-
export type StrategyDefinition = {
|
|
207
|
-
readonly id: string;
|
|
208
|
-
readonly members: readonly string[];
|
|
209
|
-
} & ({
|
|
210
|
-
readonly algorithm: PortableAlgorithm;
|
|
211
|
-
readonly implementations?: StrategyImplementations;
|
|
212
158
|
} | {
|
|
213
|
-
readonly algorithm?: never;
|
|
214
|
-
readonly implementations: StrategyImplementations;
|
|
215
|
-
});
|
|
216
|
-
export type Strategy = StrategyDefinition & {
|
|
217
|
-
readonly type: "strategy";
|
|
218
|
-
};
|
|
219
|
-
export type StrategySelection = {
|
|
220
|
-
readonly id: string;
|
|
221
|
-
readonly engine: Engine;
|
|
222
|
-
readonly algorithm: GroupAlgorithm;
|
|
223
|
-
readonly members: readonly string[];
|
|
224
|
-
readonly requestedAlgorithm?: PortableAlgorithm;
|
|
225
|
-
readonly implementationSource?: "default" | "override";
|
|
226
|
-
};
|
|
227
|
-
export type ConcreteGroup = {
|
|
228
|
-
readonly id: string;
|
|
229
159
|
readonly type: "select";
|
|
230
|
-
readonly members: readonly string[];
|
|
231
|
-
} | {
|
|
232
|
-
readonly id: string;
|
|
233
|
-
readonly type: "smart";
|
|
234
|
-
readonly members: readonly string[];
|
|
235
160
|
} | {
|
|
236
|
-
readonly id: string;
|
|
237
161
|
readonly type: "surge-smart";
|
|
238
|
-
readonly members: readonly string[];
|
|
239
162
|
} | {
|
|
240
|
-
readonly id: string;
|
|
241
163
|
readonly type: "urltest";
|
|
242
|
-
readonly members: readonly string[];
|
|
243
164
|
readonly url: string;
|
|
244
165
|
readonly intervalSeconds?: number;
|
|
245
166
|
readonly toleranceMs?: number;
|
|
246
167
|
};
|
|
247
|
-
|
|
248
|
-
readonly type: "surge-smart";
|
|
249
|
-
}> | Strategy;
|
|
250
|
-
export type Engine = "surge" | "sing-box" | "mihomo" | "stash";
|
|
251
|
-
export type DnsRule = {
|
|
168
|
+
type DnsRule = {
|
|
252
169
|
readonly pattern: string;
|
|
253
170
|
readonly server: string;
|
|
254
171
|
};
|
|
255
|
-
|
|
172
|
+
type Tun = {
|
|
256
173
|
readonly address: readonly string[];
|
|
257
174
|
readonly stack: "system" | "gvisor" | "mixed";
|
|
258
175
|
readonly autoRoute: boolean;
|
|
@@ -260,87 +177,85 @@ export type Tun = {
|
|
|
260
177
|
readonly dnsMode: "disabled" | "native" | "hijack";
|
|
261
178
|
readonly routeExcludeAddress?: readonly string[];
|
|
262
179
|
};
|
|
263
|
-
|
|
264
|
-
readonly
|
|
265
|
-
readonly
|
|
266
|
-
readonly
|
|
267
|
-
readonly
|
|
268
|
-
readonly
|
|
269
|
-
readonly
|
|
270
|
-
readonly
|
|
271
|
-
readonly fallback: Action;
|
|
272
|
-
readonly listener?: {
|
|
273
|
-
readonly port: number;
|
|
274
|
-
readonly resolver: string;
|
|
275
|
-
};
|
|
180
|
+
type Diagnostic = {
|
|
181
|
+
readonly profile?: string;
|
|
182
|
+
readonly origin?: Origin;
|
|
183
|
+
readonly severity: "error" | "warning";
|
|
184
|
+
readonly code: string;
|
|
185
|
+
readonly path: string;
|
|
186
|
+
readonly message: string;
|
|
187
|
+
readonly target?: string;
|
|
276
188
|
};
|
|
277
|
-
|
|
278
|
-
readonly
|
|
279
|
-
readonly program: string;
|
|
280
|
-
readonly engine: Engine;
|
|
281
|
-
readonly platform: "macos" | "linux";
|
|
282
|
-
readonly version: string;
|
|
283
|
-
readonly mode?: "fragment" | "standalone";
|
|
189
|
+
type ProfileDiagnostic = Omit<Diagnostic, "target" | "profile"> & {
|
|
190
|
+
readonly profile: string;
|
|
284
191
|
};
|
|
285
|
-
|
|
286
|
-
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/model/routing-types.d.ts
|
|
194
|
+
type RouteRequest = {
|
|
195
|
+
readonly network?: "tcp" | "udp";
|
|
287
196
|
readonly domain?: string;
|
|
288
|
-
readonly
|
|
289
|
-
readonly httpHost?: string;
|
|
197
|
+
readonly sniffedDomain?: string;
|
|
290
198
|
readonly ip?: string;
|
|
291
|
-
readonly
|
|
292
|
-
readonly
|
|
199
|
+
readonly resolvedIp?: string;
|
|
200
|
+
readonly asn?: number;
|
|
293
201
|
readonly port?: number;
|
|
202
|
+
readonly sourceIp?: string;
|
|
294
203
|
readonly sourcePort?: number;
|
|
204
|
+
readonly processName?: string;
|
|
205
|
+
readonly macAddress?: string;
|
|
295
206
|
};
|
|
296
|
-
|
|
297
|
-
readonly
|
|
298
|
-
readonly
|
|
299
|
-
readonly request: Request;
|
|
300
|
-
readonly expect: {
|
|
301
|
-
readonly rule?: string;
|
|
302
|
-
readonly action: Action;
|
|
303
|
-
};
|
|
304
|
-
};
|
|
305
|
-
export type Config = {
|
|
306
|
-
readonly outDir?: string;
|
|
307
|
-
readonly programs: Readonly<Record<string, Program>>;
|
|
308
|
-
readonly targets: readonly Target[];
|
|
309
|
-
readonly cases?: readonly PolicyCase[];
|
|
310
|
-
readonly warningsAsErrors?: boolean;
|
|
207
|
+
type Assumptions = {
|
|
208
|
+
readonly hit?: readonly RuleSet[];
|
|
209
|
+
readonly miss?: readonly RuleSet[];
|
|
311
210
|
};
|
|
312
|
-
|
|
313
|
-
readonly
|
|
314
|
-
readonly
|
|
315
|
-
readonly
|
|
316
|
-
readonly
|
|
317
|
-
readonly target?: string;
|
|
211
|
+
type RouteCase = {
|
|
212
|
+
readonly name: string;
|
|
213
|
+
readonly request: RouteRequest;
|
|
214
|
+
readonly assume?: Assumptions;
|
|
215
|
+
readonly expect: Exit;
|
|
318
216
|
};
|
|
319
|
-
|
|
217
|
+
type Need = {
|
|
218
|
+
readonly kind: "ruleSet";
|
|
320
219
|
readonly id: string;
|
|
321
|
-
|
|
322
|
-
readonly
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
readonly
|
|
328
|
-
readonly
|
|
329
|
-
readonly
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
readonly
|
|
334
|
-
readonly action: Action;
|
|
220
|
+
} | {
|
|
221
|
+
readonly kind: "dns";
|
|
222
|
+
} | {
|
|
223
|
+
readonly kind: "asn";
|
|
224
|
+
};
|
|
225
|
+
type Explanation = {
|
|
226
|
+
readonly outcome: "matched" | "fallback" | "indeterminate";
|
|
227
|
+
readonly exit?: string;
|
|
228
|
+
readonly route?: {
|
|
229
|
+
readonly index: number;
|
|
230
|
+
readonly origin?: Origin;
|
|
231
|
+
};
|
|
232
|
+
readonly needs?: Need;
|
|
335
233
|
readonly trace: readonly {
|
|
336
|
-
readonly
|
|
337
|
-
readonly
|
|
338
|
-
readonly
|
|
234
|
+
readonly index: number;
|
|
235
|
+
readonly matched: boolean | null;
|
|
236
|
+
readonly origin?: Origin;
|
|
339
237
|
}[];
|
|
340
238
|
};
|
|
239
|
+
type ExplainResult = {
|
|
240
|
+
readonly ok: true;
|
|
241
|
+
readonly explanation: Explanation;
|
|
242
|
+
} | {
|
|
243
|
+
readonly ok: false;
|
|
244
|
+
readonly diagnostics: readonly ProfileDiagnostic[];
|
|
245
|
+
};
|
|
246
|
+
type CaseResult = {
|
|
247
|
+
readonly name: string;
|
|
248
|
+
readonly profile: string;
|
|
249
|
+
readonly ok: boolean;
|
|
250
|
+
readonly outcome: Explanation["outcome"] | "skipped";
|
|
251
|
+
readonly expected: string;
|
|
252
|
+
readonly actual?: string;
|
|
253
|
+
readonly needs?: Need;
|
|
254
|
+
readonly route?: Explanation["route"];
|
|
255
|
+
};
|
|
341
256
|
//#endregion
|
|
342
|
-
//#region src/surge-
|
|
343
|
-
declare const policy
|
|
257
|
+
//#region src/model/surge-schema.d.ts
|
|
258
|
+
declare const policy: z.ZodUnion<readonly [z.ZodObject<{
|
|
344
259
|
ref: z.ZodString;
|
|
345
260
|
}, z.core.$strict>, z.ZodObject<{
|
|
346
261
|
builtin: z.ZodEnum<{
|
|
@@ -351,8 +266,12 @@ declare const policy$1: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
351
266
|
"REJECT-TINYGIF": "REJECT-TINYGIF";
|
|
352
267
|
}>;
|
|
353
268
|
}, z.core.$strict>]>;
|
|
354
|
-
type SurgePolicy = z.infer<typeof policy
|
|
269
|
+
type SurgePolicy = z.infer<typeof policy>;
|
|
355
270
|
declare const generalSchema: z.ZodObject<{
|
|
271
|
+
"udp-policy-not-supported-behaviour": z.ZodOptional<z.ZodEnum<{
|
|
272
|
+
DIRECT: "DIRECT";
|
|
273
|
+
REJECT: "REJECT";
|
|
274
|
+
}>>;
|
|
356
275
|
loglevel: z.ZodOptional<z.ZodEnum<{
|
|
357
276
|
info: "info";
|
|
358
277
|
notify: "notify";
|
|
@@ -380,18 +299,12 @@ declare const generalSchema: z.ZodObject<{
|
|
|
380
299
|
"bypass-tun": z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
381
300
|
"always-real-ip": z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
382
301
|
"http-api": z.ZodOptional<z.ZodObject<{
|
|
383
|
-
password: z.
|
|
384
|
-
type: z.ZodLiteral<"env">;
|
|
385
|
-
name: z.ZodString;
|
|
386
|
-
}, z.core.$strict>;
|
|
302
|
+
password: z.ZodCustom<SecretRef, SecretRef>;
|
|
387
303
|
listen: z.ZodString;
|
|
388
304
|
}, z.core.$strict>>;
|
|
389
305
|
"http-api-web-dashboard": z.ZodOptional<z.ZodBoolean>;
|
|
390
306
|
"external-controller-access": z.ZodOptional<z.ZodObject<{
|
|
391
|
-
password: z.
|
|
392
|
-
type: z.ZodLiteral<"env">;
|
|
393
|
-
name: z.ZodString;
|
|
394
|
-
}, z.core.$strict>;
|
|
307
|
+
password: z.ZodCustom<SecretRef, SecretRef>;
|
|
395
308
|
listen: z.ZodString;
|
|
396
309
|
}, z.core.$strict>>;
|
|
397
310
|
"hijack-dns": z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -410,10 +323,7 @@ declare const tunnelSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
410
323
|
type: z.ZodLiteral<"tailscale">;
|
|
411
324
|
id: z.ZodString;
|
|
412
325
|
sectionName: z.ZodString;
|
|
413
|
-
authKey: z.
|
|
414
|
-
type: z.ZodLiteral<"env">;
|
|
415
|
-
name: z.ZodString;
|
|
416
|
-
}, z.core.$strict>;
|
|
326
|
+
authKey: z.ZodCustom<SecretRef, SecretRef>;
|
|
417
327
|
hostname: z.ZodString;
|
|
418
328
|
dnsServer: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
419
329
|
autoAddMagicDnsRule: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -422,10 +332,7 @@ declare const tunnelSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
422
332
|
type: z.ZodLiteral<"wireguard">;
|
|
423
333
|
id: z.ZodString;
|
|
424
334
|
sectionName: z.ZodString;
|
|
425
|
-
privateKey: z.
|
|
426
|
-
type: z.ZodLiteral<"env">;
|
|
427
|
-
name: z.ZodString;
|
|
428
|
-
}, z.core.$strict>;
|
|
335
|
+
privateKey: z.ZodCustom<SecretRef, SecretRef>;
|
|
429
336
|
selfIp: z.ZodString;
|
|
430
337
|
dnsServer: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
431
338
|
mtu: z.ZodOptional<z.ZodNumber>;
|
|
@@ -433,14 +340,11 @@ declare const tunnelSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
433
340
|
publicKey: z.ZodString;
|
|
434
341
|
endpoint: z.ZodString;
|
|
435
342
|
allowedIps: z.ZodArray<z.ZodString>;
|
|
436
|
-
presharedKey: z.ZodOptional<z.
|
|
437
|
-
type: z.ZodLiteral<"env">;
|
|
438
|
-
name: z.ZodString;
|
|
439
|
-
}, z.core.$strict>>;
|
|
343
|
+
presharedKey: z.ZodOptional<z.ZodCustom<SecretRef, SecretRef>>;
|
|
440
344
|
persistentKeepalive: z.ZodOptional<z.ZodNumber>;
|
|
441
345
|
}, z.core.$strict>>;
|
|
442
346
|
}, z.core.$strict>], "type">;
|
|
443
|
-
type SurgeTunnel = z.infer<typeof tunnelSchema>;
|
|
347
|
+
type SurgeTunnel$1 = z.infer<typeof tunnelSchema>;
|
|
444
348
|
declare const groupSchema: z.ZodObject<{
|
|
445
349
|
id: z.ZodString;
|
|
446
350
|
type: z.ZodEnum<{
|
|
@@ -505,10 +409,7 @@ type SurgeRule = {
|
|
|
505
409
|
};
|
|
506
410
|
declare const managedSchema: z.ZodObject<{
|
|
507
411
|
url: z.ZodString;
|
|
508
|
-
query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.
|
|
509
|
-
type: z.ZodLiteral<"env">;
|
|
510
|
-
name: z.ZodString;
|
|
511
|
-
}, z.core.$strict>]>>>;
|
|
412
|
+
query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodCustom<SecretRef, SecretRef>]>>>;
|
|
512
413
|
intervalSeconds: z.ZodNumber;
|
|
513
414
|
strict: z.ZodBoolean;
|
|
514
415
|
}, z.core.$strict>;
|
|
@@ -521,261 +422,242 @@ type SurgeProfileInput = {
|
|
|
521
422
|
readonly managed?: z.infer<typeof managedSchema>;
|
|
522
423
|
readonly general?: SurgeGeneral;
|
|
523
424
|
readonly hosts?: readonly SurgeHost[];
|
|
524
|
-
readonly nodes: readonly ProxyNode[];
|
|
525
|
-
readonly tunnels?: readonly SurgeTunnel[];
|
|
425
|
+
readonly nodes: readonly ProxyNode$1[];
|
|
426
|
+
readonly tunnels?: readonly SurgeTunnel$1[];
|
|
526
427
|
readonly groups: readonly SurgeGroup[];
|
|
527
428
|
readonly rules: readonly SurgeRule[];
|
|
528
429
|
readonly fallback: SurgePolicy;
|
|
529
430
|
readonly names?: Readonly<Record<string, string>>;
|
|
530
431
|
};
|
|
531
|
-
type SurgeProfileCompilation = {
|
|
532
|
-
readonly ok: boolean;
|
|
533
|
-
readonly artifactKind: "surge-profile";
|
|
534
|
-
readonly diagnostics: readonly Diagnostic[];
|
|
535
|
-
readonly bindings: readonly {
|
|
536
|
-
readonly id: string;
|
|
537
|
-
readonly nativeName: string;
|
|
538
|
-
}[];
|
|
539
|
-
};
|
|
540
|
-
type SurgeProfileArtifact = {
|
|
541
|
-
readonly artifactKind: "surge-profile";
|
|
542
|
-
readonly content: string;
|
|
543
|
-
};
|
|
544
|
-
export declare function compileSurgeProfile(input: unknown): SurgeProfileCompilation;
|
|
545
|
-
export declare function renderSurgeProfile(compilation: SurgeProfileCompilation, resolveSecret: (token: Secret) => string | undefined): SurgeProfileArtifact;
|
|
546
|
-
export declare function renderSurgeProfiles(compilations: readonly SurgeProfileCompilation[], resolveSecret: (token: Secret) => string | undefined): readonly SurgeProfileArtifact[];
|
|
547
432
|
//#endregion
|
|
548
|
-
//#region src/
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
readonly autoGroup: "urltest";
|
|
553
|
-
readonly platforms: readonly ["linux", "macos"];
|
|
554
|
-
readonly protocols: readonly ["hysteria2", "trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
|
|
555
|
-
readonly endpoints: readonly ["sing-box-tailscale"];
|
|
556
|
-
readonly groups: readonly ["select", "urltest"];
|
|
557
|
-
readonly nativeRuleSets: readonly ["source", "binary"];
|
|
558
|
-
readonly dns: "typed";
|
|
559
|
-
}, {
|
|
560
|
-
readonly engine: "sing-box";
|
|
561
|
-
readonly version: "1.11.0";
|
|
562
|
-
readonly autoGroup: "urltest";
|
|
563
|
-
readonly platforms: readonly ["linux", "macos"];
|
|
564
|
-
readonly protocols: readonly ["hysteria2", "trojan", "http", "shadowsocks", "vmess", "vless"];
|
|
565
|
-
readonly endpoints: readonly [];
|
|
566
|
-
readonly groups: readonly ["select", "urltest"];
|
|
567
|
-
readonly nativeRuleSets: readonly ["source", "binary"];
|
|
568
|
-
readonly dns: "legacy";
|
|
569
|
-
}, {
|
|
570
|
-
readonly engine: "sing-box";
|
|
571
|
-
readonly version: "1.12.0";
|
|
572
|
-
readonly autoGroup: "urltest";
|
|
573
|
-
readonly platforms: readonly ["linux", "macos"];
|
|
574
|
-
readonly protocols: readonly ["hysteria2", "trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
|
|
575
|
-
readonly endpoints: readonly ["sing-box-tailscale"];
|
|
576
|
-
readonly groups: readonly ["select", "urltest"];
|
|
577
|
-
readonly nativeRuleSets: readonly ["source", "binary"];
|
|
578
|
-
readonly dns: "typed";
|
|
579
|
-
}, {
|
|
433
|
+
//#region src/model/profile-types.d.ts
|
|
434
|
+
type DeepReadonly<T> = T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]>; } : T;
|
|
435
|
+
type Fragments<T> = T | readonly Fragments<T>[];
|
|
436
|
+
type Target = {
|
|
580
437
|
readonly engine: "surge";
|
|
438
|
+
readonly platform: "ios";
|
|
439
|
+
readonly version: "5.21.0";
|
|
440
|
+
} | {
|
|
441
|
+
readonly engine: "surge";
|
|
442
|
+
readonly platform: "macos";
|
|
581
443
|
readonly version: "6.10.0";
|
|
582
|
-
|
|
583
|
-
readonly
|
|
584
|
-
readonly
|
|
585
|
-
readonly
|
|
586
|
-
|
|
587
|
-
readonly nativeRuleSets: readonly ["rule-set", "domain-set"];
|
|
588
|
-
readonly dns: "general";
|
|
589
|
-
}, {
|
|
444
|
+
} | {
|
|
445
|
+
readonly engine: "sing-box";
|
|
446
|
+
readonly platform: "macos" | "linux";
|
|
447
|
+
readonly version: "1.12.0" | "1.14.4";
|
|
448
|
+
} | {
|
|
590
449
|
readonly engine: "mihomo";
|
|
450
|
+
readonly platform: "macos" | "linux";
|
|
591
451
|
readonly version: "1.19.32";
|
|
592
|
-
|
|
593
|
-
readonly platforms: readonly ["linux", "macos"];
|
|
594
|
-
readonly protocols: readonly ["hysteria2", "trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
|
|
595
|
-
readonly endpoints: readonly [];
|
|
596
|
-
readonly groups: readonly ["select", "urltest"];
|
|
597
|
-
readonly nativeRuleSets: readonly ["yaml", "text"];
|
|
598
|
-
readonly dns: "clash";
|
|
599
|
-
}, {
|
|
452
|
+
} | {
|
|
600
453
|
readonly engine: "stash";
|
|
454
|
+
readonly platform: "macos";
|
|
601
455
|
readonly version: "4.2.1";
|
|
602
|
-
readonly autoGroup: null;
|
|
603
|
-
readonly platforms: readonly ["macos"];
|
|
604
|
-
readonly protocols: readonly ["hysteria2", "trojan", "http", "anytls", "shadowsocks", "vmess"];
|
|
605
|
-
readonly endpoints: readonly [];
|
|
606
|
-
readonly groups: readonly ["select"];
|
|
607
|
-
readonly nativeRuleSets: readonly [];
|
|
608
|
-
readonly dns: "external";
|
|
609
|
-
}];
|
|
610
|
-
//#endregion
|
|
611
|
-
//#region src/compiler.d.ts
|
|
612
|
-
type TargetPlan = {
|
|
613
|
-
readonly target: Target;
|
|
614
|
-
readonly program: Omit<Program, "groups"> & {
|
|
615
|
-
readonly groups: readonly ConcreteGroup[];
|
|
616
|
-
};
|
|
617
|
-
readonly nativeRuleSets: readonly NativeRuleSet[];
|
|
618
|
-
readonly strategySelections: readonly StrategySelection[];
|
|
619
|
-
readonly rules: readonly ExpandedRule[];
|
|
620
|
-
readonly sourceMap: readonly {
|
|
621
|
-
readonly rule: string;
|
|
622
|
-
readonly nativeIndex: number;
|
|
623
|
-
readonly origin: readonly string[];
|
|
624
|
-
}[];
|
|
625
|
-
readonly preconditions: readonly string[];
|
|
626
|
-
readonly nativeValidation: "not-run";
|
|
627
456
|
};
|
|
628
|
-
type
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
readonly
|
|
633
|
-
|
|
634
|
-
|
|
457
|
+
type SecretRef = Secret & SDK<"secret">;
|
|
458
|
+
type Secrets<T extends string = string> = Readonly<Record<T, SecretRef>> & SDK<"secrets">;
|
|
459
|
+
type PublicSecrets<T> = T extends Secret ? SecretRef : T extends readonly (infer V)[] ? readonly PublicSecrets<V>[] : T extends object ? { readonly [K in keyof T]: PublicSecrets<T[K]>; } : T;
|
|
460
|
+
type NodeOf<N> = N extends ProxyNode$1 ? Omit<PublicSecrets<N>, "via" | "label"> & {
|
|
461
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
462
|
+
readonly name?: string;
|
|
463
|
+
} & SDK<"node"> : never;
|
|
464
|
+
type ProxyNode = NodeOf<ProxyNode$1>;
|
|
465
|
+
type ProxyGroup<A extends GroupAlgorithm = GroupAlgorithm> = {
|
|
466
|
+
readonly type: "proxy-group";
|
|
635
467
|
readonly id: string;
|
|
636
|
-
readonly
|
|
637
|
-
readonly
|
|
638
|
-
|
|
639
|
-
|
|
468
|
+
readonly name?: string;
|
|
469
|
+
readonly algorithm: A;
|
|
470
|
+
readonly members: readonly Exit[];
|
|
471
|
+
readonly surge?: {
|
|
472
|
+
readonly url: string;
|
|
473
|
+
readonly intervalSeconds?: number;
|
|
474
|
+
readonly timeoutSeconds?: number;
|
|
640
475
|
};
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
readonly
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
476
|
+
} & SDK<"group">;
|
|
477
|
+
type SurgeTunnel = PublicSecrets<SurgeTunnel$1> & {
|
|
478
|
+
readonly name?: string;
|
|
479
|
+
} & SDK<"tunnel">;
|
|
480
|
+
type SingBoxEndpoint = PublicSecrets<TailscaleEndpoint> & {
|
|
481
|
+
readonly name?: string;
|
|
482
|
+
} & SDK<"endpoint">;
|
|
483
|
+
type Builtin = {
|
|
484
|
+
readonly builtin: "DIRECT" | "REJECT" | "REJECT-DROP" | "REJECT-NO-DROP" | "REJECT-TINYGIF";
|
|
485
|
+
} & SDK<"builtin">;
|
|
486
|
+
type Exit = ProxyNode | ProxyGroup | SurgeTunnel | SingBoxEndpoint | Builtin;
|
|
487
|
+
type ProfileProxy = ProxyNode | SurgeTunnel | SingBoxEndpoint;
|
|
488
|
+
type ExternalRuleSet = {
|
|
489
|
+
readonly type: "ruleSetSource";
|
|
652
490
|
readonly id: string;
|
|
653
|
-
readonly
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
readonly
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
rejectNoDrop: Readonly<{
|
|
681
|
-
readonly builtin: "REJECT-NO-DROP";
|
|
682
|
-
}>;
|
|
683
|
-
rejectTinyGif: Readonly<{
|
|
684
|
-
readonly builtin: "REJECT-TINYGIF";
|
|
685
|
-
}>;
|
|
686
|
-
};
|
|
687
|
-
export declare function defineProxyGroup(input: Omit<ProxyGroupDefinition, "type">): ProxyGroupDefinition;
|
|
688
|
-
export declare function defineRoute(input: Omit<RouteDefinition, "type">): RouteDefinition;
|
|
689
|
-
export declare function defineRoutes(input: {
|
|
690
|
-
readonly when: readonly ProfileCondition[];
|
|
691
|
-
readonly to: ProfileDestination;
|
|
692
|
-
}): RouteDefinition[];
|
|
693
|
-
//#endregion
|
|
694
|
-
//#region src/profile.d.ts
|
|
695
|
-
type DeepReadonly<T> = T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]>; } : T;
|
|
491
|
+
readonly surge?: {
|
|
492
|
+
readonly url: string;
|
|
493
|
+
readonly format?: "rule-set" | "domain-set";
|
|
494
|
+
readonly intervalSeconds?: number;
|
|
495
|
+
readonly noResolve?: boolean;
|
|
496
|
+
readonly includeSniffed?: boolean;
|
|
497
|
+
};
|
|
498
|
+
readonly singBox?: {
|
|
499
|
+
readonly url: string;
|
|
500
|
+
readonly format: "source" | "binary";
|
|
501
|
+
readonly intervalSeconds: number;
|
|
502
|
+
readonly resolve?: boolean;
|
|
503
|
+
};
|
|
504
|
+
readonly mihomo?: {
|
|
505
|
+
readonly url: string;
|
|
506
|
+
readonly format: "yaml" | "text";
|
|
507
|
+
readonly behavior: "domain" | "ipcidr" | "classical";
|
|
508
|
+
readonly intervalSeconds: number;
|
|
509
|
+
};
|
|
510
|
+
} & SDK<"ruleSet">;
|
|
511
|
+
type BuiltinRuleSet = {
|
|
512
|
+
readonly type: "ruleSet";
|
|
513
|
+
readonly id: "surge:lan" | "surge:system";
|
|
514
|
+
readonly format: "rule-set";
|
|
515
|
+
readonly builtin: "LAN" | "SYSTEM";
|
|
516
|
+
} & SDK<"ruleSet">;
|
|
517
|
+
type RuleSet = ExternalRuleSet | BuiltinRuleSet;
|
|
696
518
|
type ProfileCondition = Exclude<Match | SurgeCondition, {
|
|
697
|
-
type: "all" | "any" | "not";
|
|
698
|
-
}> | {
|
|
519
|
+
type: "all" | "any" | "not" | "nativeRuleSet" | "ruleSet";
|
|
520
|
+
}> | RuleSet | {
|
|
699
521
|
readonly type: "all" | "any";
|
|
700
522
|
readonly conditions: readonly ProfileCondition[];
|
|
701
|
-
readonly noResolve?: boolean;
|
|
702
523
|
} | {
|
|
703
524
|
readonly type: "not";
|
|
704
525
|
readonly condition: ProfileCondition;
|
|
705
|
-
readonly noResolve?: boolean;
|
|
706
|
-
};
|
|
707
|
-
type ProfileDestination = string | ProxyNode | ProxyGroupDefinition | SurgeTunnel | TailscaleEndpoint | {
|
|
708
|
-
readonly builtin: "DIRECT" | "REJECT" | "REJECT-DROP" | "REJECT-NO-DROP" | "REJECT-TINYGIF";
|
|
709
526
|
};
|
|
710
|
-
type
|
|
711
|
-
type
|
|
712
|
-
type
|
|
713
|
-
readonly
|
|
527
|
+
type Condition = ProfileCondition;
|
|
528
|
+
type Route = {
|
|
529
|
+
readonly type: "route";
|
|
530
|
+
readonly when: Condition;
|
|
531
|
+
readonly to: Exit;
|
|
532
|
+
} & SDK<"route">;
|
|
533
|
+
type SurgeConfig = {
|
|
534
|
+
readonly general?: Fragments<DeepReadonly<SurgeGeneral>>;
|
|
714
535
|
readonly hosts?: Fragments<DeepReadonly<SurgeHost>>;
|
|
536
|
+
readonly managed?: DeepReadonly<SurgeProfileInput["managed"]>;
|
|
715
537
|
};
|
|
716
|
-
type
|
|
717
|
-
readonly
|
|
718
|
-
readonly
|
|
719
|
-
readonly
|
|
720
|
-
readonly
|
|
721
|
-
readonly version: string;
|
|
538
|
+
type SingBoxOptions = {
|
|
539
|
+
readonly mode?: "standalone" | "fragment";
|
|
540
|
+
readonly listener?: {
|
|
541
|
+
readonly port: number;
|
|
542
|
+
readonly resolver: string;
|
|
722
543
|
};
|
|
544
|
+
readonly tun?: Tun;
|
|
545
|
+
readonly domainMatching?: "prefer-sniffed";
|
|
546
|
+
readonly serverAliases?: Readonly<Record<string, string>>;
|
|
547
|
+
readonly cacheFile?: boolean;
|
|
548
|
+
readonly unsupportedUdp?: "reject";
|
|
549
|
+
};
|
|
550
|
+
type Common = {
|
|
551
|
+
readonly cases?: Fragments<RouteCase>;
|
|
552
|
+
readonly dns?: Fragments<DnsRule>;
|
|
723
553
|
readonly proxies: Fragments<ProfileProxy>;
|
|
724
|
-
readonly
|
|
725
|
-
readonly
|
|
726
|
-
readonly fallback: ProfileDestination;
|
|
727
|
-
readonly surge?: SurgeConfig;
|
|
728
|
-
readonly singBox?: {
|
|
729
|
-
readonly mode: "fragment" | "standalone";
|
|
730
|
-
readonly tun?: Tun;
|
|
731
|
-
readonly listener?: {
|
|
732
|
-
readonly port: number;
|
|
733
|
-
readonly resolver: string;
|
|
734
|
-
};
|
|
735
|
-
};
|
|
554
|
+
readonly routes: Fragments<Route>;
|
|
555
|
+
readonly fallback: Exit;
|
|
736
556
|
};
|
|
737
|
-
type
|
|
738
|
-
|
|
739
|
-
readonly proxies: readonly ProfileProxy[];
|
|
740
|
-
readonly groups: readonly ProxyGroupDefinition[];
|
|
741
|
-
readonly routes: readonly RouteDefinition[];
|
|
742
|
-
readonly surge?: Pick<SurgeProfileInput, "managed" | "general" | "hosts" | "names">;
|
|
557
|
+
type Portable = Exclude<GroupAlgorithm, {
|
|
558
|
+
type: "surge-smart";
|
|
743
559
|
}>;
|
|
744
|
-
type
|
|
745
|
-
readonly
|
|
746
|
-
|
|
747
|
-
|
|
560
|
+
type ProfileDefinition = Common & ({
|
|
561
|
+
readonly target: Extract<Target, {
|
|
562
|
+
engine: "surge";
|
|
563
|
+
}>;
|
|
564
|
+
readonly groups: Fragments<ProxyGroup>;
|
|
565
|
+
readonly surge?: SurgeConfig;
|
|
566
|
+
readonly singBox?: never;
|
|
567
|
+
readonly mihomo?: never;
|
|
748
568
|
} | {
|
|
749
|
-
readonly
|
|
750
|
-
|
|
751
|
-
|
|
569
|
+
readonly target: Extract<Target, {
|
|
570
|
+
engine: "sing-box";
|
|
571
|
+
}>;
|
|
572
|
+
readonly groups: Fragments<ProxyGroup<Portable>>;
|
|
573
|
+
readonly singBox?: SingBoxOptions;
|
|
574
|
+
readonly surge?: never;
|
|
575
|
+
readonly mihomo?: never;
|
|
752
576
|
} | {
|
|
753
|
-
readonly
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
readonly
|
|
577
|
+
readonly target: Extract<Target, {
|
|
578
|
+
engine: "mihomo";
|
|
579
|
+
}>;
|
|
580
|
+
readonly groups: Fragments<ProxyGroup<Portable>>;
|
|
581
|
+
readonly mihomo?: Pick<SingBoxOptions, "mode" | "listener">;
|
|
582
|
+
readonly surge?: never;
|
|
583
|
+
readonly singBox?: never;
|
|
584
|
+
} | {
|
|
585
|
+
readonly target: Extract<Target, {
|
|
586
|
+
engine: "stash";
|
|
587
|
+
}>;
|
|
588
|
+
readonly groups: Fragments<ProxyGroup<Portable>>;
|
|
589
|
+
readonly surge?: never;
|
|
590
|
+
readonly singBox?: never;
|
|
591
|
+
readonly mihomo?: never;
|
|
592
|
+
});
|
|
593
|
+
type ResolvedSurge = {
|
|
594
|
+
readonly general?: DeepReadonly<SurgeGeneral>;
|
|
595
|
+
readonly hosts?: readonly DeepReadonly<SurgeHost>[];
|
|
596
|
+
readonly managed?: DeepReadonly<SurgeProfileInput["managed"]>;
|
|
757
597
|
};
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
598
|
+
type FlattenedProfile<D extends ProfileDefinition> = D extends ProfileDefinition ? Omit<D, "proxies" | "groups" | "routes" | "dns" | "cases" | "surge"> & {
|
|
599
|
+
readonly proxies: readonly ProfileProxy[];
|
|
600
|
+
readonly groups: readonly (D extends {
|
|
601
|
+
target: {
|
|
602
|
+
engine: "surge";
|
|
603
|
+
};
|
|
604
|
+
} ? ProxyGroup : ProxyGroup<Portable>)[];
|
|
605
|
+
readonly routes: readonly Route[];
|
|
606
|
+
readonly dns: readonly DnsRule[];
|
|
607
|
+
readonly cases: readonly RouteCase[];
|
|
608
|
+
readonly surge?: D extends {
|
|
609
|
+
target: {
|
|
610
|
+
engine: "surge";
|
|
611
|
+
};
|
|
612
|
+
} ? ResolvedSurge : never;
|
|
613
|
+
} : never;
|
|
614
|
+
type Profile<D extends ProfileDefinition = ProfileDefinition> = FlattenedProfile<D> & SDK<"profile">;
|
|
615
|
+
//#endregion
|
|
616
|
+
//#region src/authoring/profile.d.ts
|
|
617
|
+
export declare function defineProfile<const D extends ProfileDefinition>(input: D): Profile<D>;
|
|
762
618
|
//#endregion
|
|
763
|
-
//#region src/
|
|
619
|
+
//#region src/authoring/resources.d.ts
|
|
620
|
+
export declare const outbound: {
|
|
621
|
+
direct: {
|
|
622
|
+
builtin: "DIRECT";
|
|
623
|
+
} & SDK<"builtin">;
|
|
624
|
+
reject: {
|
|
625
|
+
builtin: "REJECT";
|
|
626
|
+
} & SDK<"builtin">;
|
|
627
|
+
rejectDrop: {
|
|
628
|
+
builtin: "REJECT-DROP";
|
|
629
|
+
} & SDK<"builtin">;
|
|
630
|
+
rejectNoDrop: {
|
|
631
|
+
builtin: "REJECT-NO-DROP";
|
|
632
|
+
} & SDK<"builtin">;
|
|
633
|
+
rejectTinyGif: {
|
|
634
|
+
builtin: "REJECT-TINYGIF";
|
|
635
|
+
} & SDK<"builtin">;
|
|
636
|
+
};
|
|
637
|
+
export declare function defineProxyGroup<const A extends GroupAlgorithm>(input: {
|
|
638
|
+
readonly id: string;
|
|
639
|
+
readonly name?: string;
|
|
640
|
+
readonly algorithm: A;
|
|
641
|
+
readonly members: Fragments<Exit>;
|
|
642
|
+
readonly surge?: ProxyGroup<A>["surge"];
|
|
643
|
+
}): ProxyGroup<A>;
|
|
644
|
+
export declare function defineRoutes(input: {
|
|
645
|
+
readonly when: Fragments<Condition>;
|
|
646
|
+
readonly to: Exit;
|
|
647
|
+
}): Route[];
|
|
648
|
+
//#endregion
|
|
649
|
+
//#region src/authoring/proxy-builder.d.ts
|
|
764
650
|
type ProxyBuilder<N extends ProxyNode> = {
|
|
765
|
-
readonly via: (
|
|
766
|
-
readonly
|
|
651
|
+
readonly via: (exit: ProxyNode | ProxyGroup) => ProxyBuilder<N>;
|
|
652
|
+
readonly name: (text: string) => ProxyBuilder<N>;
|
|
767
653
|
readonly tcpFastOpen: (enabled: boolean) => ProxyBuilder<N>;
|
|
768
654
|
readonly build: () => N;
|
|
769
655
|
};
|
|
770
|
-
|
|
771
|
-
declare function proxyBuilder<N extends ProxyNode>(node: N): ProxyBuilder<Extract<ProxyNode, {
|
|
772
|
-
type: N["type"];
|
|
773
|
-
}>>;
|
|
656
|
+
declare function proxyBuilder<N extends ProxyNode>(node: N): ProxyBuilder<N>;
|
|
774
657
|
//#endregion
|
|
775
|
-
//#region src/
|
|
658
|
+
//#region src/authoring/constructors.d.ts
|
|
776
659
|
export declare function dnsRule(pattern: string, server: string): DnsRule;
|
|
777
|
-
export declare function dnsRule(
|
|
778
|
-
export declare const ruleSet: (definition: Omit<NamedRuleSet, "type">) => NamedRuleSet;
|
|
660
|
+
export declare function dnsRule(pattern: readonly string[], server: string): DnsRule[];
|
|
779
661
|
type DomainOptions = {
|
|
780
662
|
readonly includeSniffed?: boolean;
|
|
781
663
|
};
|
|
@@ -783,436 +665,575 @@ type IpOptions = {
|
|
|
783
665
|
readonly noResolve?: boolean;
|
|
784
666
|
};
|
|
785
667
|
export declare const match: {
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
};
|
|
796
|
-
domainSuffix: (value: string, opts?: DomainOptions) => {
|
|
797
|
-
includeSniffed?: boolean;
|
|
798
|
-
type: "domainSuffix";
|
|
799
|
-
value: string;
|
|
668
|
+
domain: {
|
|
669
|
+
(value: string, options?: DomainOptions | undefined): {
|
|
670
|
+
readonly type: "domain";
|
|
671
|
+
readonly value: string;
|
|
672
|
+
} & DomainOptions;
|
|
673
|
+
(value: readonly string[], options?: DomainOptions | undefined): ({
|
|
674
|
+
readonly type: "domain";
|
|
675
|
+
readonly value: string;
|
|
676
|
+
} & DomainOptions)[];
|
|
800
677
|
};
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
678
|
+
domainSuffix: {
|
|
679
|
+
(value: string, options?: DomainOptions | undefined): {
|
|
680
|
+
readonly type: "domainSuffix";
|
|
681
|
+
readonly value: string;
|
|
682
|
+
} & DomainOptions;
|
|
683
|
+
(value: readonly string[], options?: DomainOptions | undefined): ({
|
|
684
|
+
readonly type: "domainSuffix";
|
|
685
|
+
readonly value: string;
|
|
686
|
+
} & DomainOptions)[];
|
|
805
687
|
};
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
688
|
+
ipCidr: {
|
|
689
|
+
(value: string, options?: IpOptions | undefined): {
|
|
690
|
+
readonly type: "ipCidr";
|
|
691
|
+
readonly value: string;
|
|
692
|
+
} & IpOptions;
|
|
693
|
+
(value: readonly string[], options?: IpOptions | undefined): ({
|
|
694
|
+
readonly type: "ipCidr";
|
|
695
|
+
readonly value: string;
|
|
696
|
+
} & IpOptions)[];
|
|
809
697
|
};
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
698
|
+
sourceIp: {
|
|
699
|
+
(value: string, options?: Record<string, never> | undefined): {
|
|
700
|
+
readonly type: "sourceIp";
|
|
701
|
+
readonly value: string;
|
|
702
|
+
} & Record<string, never>;
|
|
703
|
+
(value: readonly string[], options?: Record<string, never> | undefined): ({
|
|
704
|
+
readonly type: "sourceIp";
|
|
705
|
+
readonly value: string;
|
|
706
|
+
} & Record<string, never>)[];
|
|
814
707
|
};
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
708
|
+
processName: {
|
|
709
|
+
(value: string, options?: Record<string, never> | undefined): {
|
|
710
|
+
readonly type: "processName";
|
|
711
|
+
readonly value: string;
|
|
712
|
+
} & Record<string, never>;
|
|
713
|
+
(value: readonly string[], options?: Record<string, never> | undefined): ({
|
|
714
|
+
readonly type: "processName";
|
|
715
|
+
readonly value: string;
|
|
716
|
+
} & Record<string, never>)[];
|
|
819
717
|
};
|
|
820
|
-
|
|
718
|
+
port: (from: number, to?: number) => Extract<Condition, {
|
|
719
|
+
type: "port" | "sourcePort";
|
|
720
|
+
}>;
|
|
721
|
+
sourcePort: (from: number, to?: number) => Extract<Condition, {
|
|
722
|
+
type: "port" | "sourcePort";
|
|
723
|
+
}>;
|
|
724
|
+
network: (value: Network) => Extract<Condition, {
|
|
821
725
|
type: "network";
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
not: <const C extends ProfileCondition>(condition: C) => {
|
|
726
|
+
}>;
|
|
727
|
+
all: (...conditions: readonly Fragments<Condition>[]) => {
|
|
728
|
+
type: "all" | "any";
|
|
729
|
+
conditions: ProfileCondition[];
|
|
730
|
+
} & SDK<"condition">;
|
|
731
|
+
any: (...conditions: readonly Fragments<Condition>[]) => {
|
|
732
|
+
type: "all" | "any";
|
|
733
|
+
conditions: ProfileCondition[];
|
|
734
|
+
} & SDK<"condition">;
|
|
735
|
+
not: (condition: Condition) => {
|
|
833
736
|
type: "not";
|
|
834
|
-
condition:
|
|
835
|
-
}
|
|
737
|
+
condition: ProfileCondition;
|
|
738
|
+
} & SDK<"condition">;
|
|
836
739
|
};
|
|
837
|
-
|
|
838
|
-
engine: E;
|
|
839
|
-
}>;
|
|
840
|
-
type NativeInput<E extends NativeRuleSet["engine"]> = Omit<NativeFor<E>, "type" | "engine" | "id"> & {
|
|
841
|
-
readonly id?: string;
|
|
842
|
-
};
|
|
843
|
-
type SurgeSetInput = Omit<NativeInput<"surge">, "format"> & {
|
|
844
|
-
readonly format?: "rule-set" | "domain-set";
|
|
845
|
-
};
|
|
846
|
-
export declare const direct: () => Action;
|
|
847
|
-
export declare const reject: () => Action;
|
|
848
|
-
export declare const route: (to: string) => Action;
|
|
849
|
-
/** An exit parameter declared by policy.exits and resolved by use.bindings. */
|
|
850
|
-
export declare const slot: <const S extends string>(name: S) => Slot<S>;
|
|
851
|
-
export declare const secret: (name: string) => Secret;
|
|
852
|
-
export declare const rule: <const S extends string = never>(id: string, when: Match, then: Action | Slot<S>) => Rule<S>;
|
|
853
|
-
export declare const block: <const S extends string = never>(id: string, rules: readonly Entry<S>[], when?: Match) => Block<S>;
|
|
854
|
-
type CheckedEntries<S extends string, R extends readonly Entry[]> = R & (string extends (R[number] extends Entry<infer Used> ? Used : never) ? unknown : readonly Entry<S>[]);
|
|
855
|
-
export declare const policy: <const S extends string, const R extends readonly Entry[] = readonly Entry<S>[]>(definition: Omit<Policy<S>, "type" | "rules"> & {
|
|
856
|
-
readonly rules: CheckedEntries<NoInfer<S>, R>;
|
|
857
|
-
}) => Policy<S>;
|
|
858
|
-
export declare const use: <S extends string, const B extends Record<NoInfer<S>, Action | Slot>>(definition: Policy<S>, options: {
|
|
859
|
-
id: string;
|
|
860
|
-
bindings: B & Record<Exclude<keyof B, S>, never>;
|
|
861
|
-
}) => Use<Extract<B[keyof B], Slot>["name"]>;
|
|
862
|
-
export declare const sequence: <const S extends string = never>(...parts: readonly (Entry<S> | readonly Entry<S>[])[]) => Entry<S>[];
|
|
863
|
-
export declare const defineConfig: <const T extends Config>(config: T & {
|
|
864
|
-
readonly targets: readonly (Config["targets"][number] & {
|
|
865
|
-
readonly program: string extends NoInfer<T>["targets"][number]["program"] ? string : keyof NoInfer<T>["programs"] & string;
|
|
866
|
-
})[];
|
|
867
|
-
readonly cases?: readonly (NonNullable<Config["cases"]>[number] & {
|
|
868
|
-
readonly program: string extends NonNullable<NoInfer<T>["cases"]>[number]["program"] ? string : keyof NoInfer<T>["programs"] & string;
|
|
869
|
-
})[];
|
|
870
|
-
}) => T;
|
|
871
|
-
/** A shared strategy declares an algorithm or explicitly selects native implementations. */
|
|
872
|
-
export declare const strategy: (definition: StrategyDefinition) => Strategy;
|
|
740
|
+
export declare function ruleSet(input: Omit<ExternalRuleSet, "type" | keyof SDK<"ruleSet">>): RuleSet;
|
|
873
741
|
export declare const group: {
|
|
874
742
|
auto: () => {
|
|
875
|
-
|
|
876
|
-
}
|
|
877
|
-
select: () =>
|
|
743
|
+
type: "auto";
|
|
744
|
+
} & SDK<"algorithm">;
|
|
745
|
+
select: () => {
|
|
878
746
|
type: "select";
|
|
879
|
-
}>;
|
|
880
|
-
urltest: (
|
|
747
|
+
} & SDK<"algorithm">;
|
|
748
|
+
urltest: (input: Omit<Extract<GroupAlgorithm, {
|
|
881
749
|
type: "urltest";
|
|
882
|
-
}>, "type">) =>
|
|
750
|
+
}>, "type">) => {
|
|
751
|
+
url: string;
|
|
752
|
+
intervalSeconds?: number;
|
|
753
|
+
toleranceMs?: number;
|
|
883
754
|
type: "urltest";
|
|
884
|
-
}>;
|
|
755
|
+
} & SDK<"algorithm">;
|
|
756
|
+
};
|
|
757
|
+
type Input<T extends object> = Omit<T, "type" | keyof SDK<string>>;
|
|
758
|
+
export declare const proxy: {
|
|
759
|
+
builder: typeof proxyBuilder;
|
|
760
|
+
http: (input: Input<Omit<{
|
|
761
|
+
readonly id: string;
|
|
762
|
+
readonly server: string;
|
|
763
|
+
readonly port: number;
|
|
764
|
+
readonly via?: string;
|
|
765
|
+
readonly tcpFastOpen?: boolean;
|
|
766
|
+
readonly type: "http";
|
|
767
|
+
readonly serverName?: never;
|
|
768
|
+
readonly password: SecretRef;
|
|
769
|
+
readonly username?: SecretRef | undefined;
|
|
770
|
+
}, "label" | "via"> & {
|
|
771
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
772
|
+
readonly name?: string;
|
|
773
|
+
} & SDK<"node">>) => Omit<{
|
|
774
|
+
readonly id: string;
|
|
775
|
+
readonly server: string;
|
|
776
|
+
readonly port: number;
|
|
777
|
+
readonly via?: string;
|
|
778
|
+
readonly tcpFastOpen?: boolean;
|
|
779
|
+
readonly type: "http";
|
|
780
|
+
readonly serverName?: never;
|
|
781
|
+
readonly password: SecretRef;
|
|
782
|
+
readonly username?: SecretRef | undefined;
|
|
783
|
+
}, "label" | "via"> & {
|
|
784
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
785
|
+
readonly name?: string;
|
|
786
|
+
} & SDK<"node">;
|
|
787
|
+
trojan: (input: Input<Omit<{
|
|
788
|
+
readonly id: string;
|
|
789
|
+
readonly server: string;
|
|
790
|
+
readonly port: number;
|
|
791
|
+
readonly via?: string;
|
|
792
|
+
readonly tcpFastOpen?: boolean;
|
|
793
|
+
readonly type: "trojan";
|
|
794
|
+
readonly password: SecretRef;
|
|
795
|
+
readonly serverName?: string;
|
|
796
|
+
readonly skipCertVerify?: boolean;
|
|
797
|
+
readonly surge?: {
|
|
798
|
+
readonly blockQuic?: "auto" | "on" | "off";
|
|
799
|
+
readonly udpRelay?: true;
|
|
800
|
+
} | undefined;
|
|
801
|
+
}, "label" | "via"> & {
|
|
802
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
803
|
+
readonly name?: string;
|
|
804
|
+
} & SDK<"node">>) => Omit<{
|
|
805
|
+
readonly id: string;
|
|
806
|
+
readonly server: string;
|
|
807
|
+
readonly port: number;
|
|
808
|
+
readonly via?: string;
|
|
809
|
+
readonly tcpFastOpen?: boolean;
|
|
810
|
+
readonly type: "trojan";
|
|
811
|
+
readonly password: SecretRef;
|
|
812
|
+
readonly serverName?: string;
|
|
813
|
+
readonly skipCertVerify?: boolean;
|
|
814
|
+
readonly surge?: {
|
|
815
|
+
readonly blockQuic?: "auto" | "on" | "off";
|
|
816
|
+
readonly udpRelay?: true;
|
|
817
|
+
} | undefined;
|
|
818
|
+
}, "label" | "via"> & {
|
|
819
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
820
|
+
readonly name?: string;
|
|
821
|
+
} & SDK<"node">;
|
|
822
|
+
anytls: (input: Input<Omit<{
|
|
823
|
+
readonly id: string;
|
|
824
|
+
readonly server: string;
|
|
825
|
+
readonly port: number;
|
|
826
|
+
readonly via?: string;
|
|
827
|
+
readonly tcpFastOpen?: boolean;
|
|
828
|
+
readonly type: "anytls";
|
|
829
|
+
readonly password: SecretRef;
|
|
830
|
+
readonly serverName?: string;
|
|
831
|
+
readonly skipCertVerify?: boolean;
|
|
832
|
+
readonly surge?: {
|
|
833
|
+
readonly blockQuic?: "auto" | "on" | "off";
|
|
834
|
+
readonly udpRelay?: true;
|
|
835
|
+
} | undefined;
|
|
836
|
+
}, "label" | "via"> & {
|
|
837
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
838
|
+
readonly name?: string;
|
|
839
|
+
} & SDK<"node">>) => Omit<{
|
|
840
|
+
readonly id: string;
|
|
841
|
+
readonly server: string;
|
|
842
|
+
readonly port: number;
|
|
843
|
+
readonly via?: string;
|
|
844
|
+
readonly tcpFastOpen?: boolean;
|
|
845
|
+
readonly type: "anytls";
|
|
846
|
+
readonly password: SecretRef;
|
|
847
|
+
readonly serverName?: string;
|
|
848
|
+
readonly skipCertVerify?: boolean;
|
|
849
|
+
readonly surge?: {
|
|
850
|
+
readonly blockQuic?: "auto" | "on" | "off";
|
|
851
|
+
readonly udpRelay?: true;
|
|
852
|
+
} | undefined;
|
|
853
|
+
}, "label" | "via"> & {
|
|
854
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
855
|
+
readonly name?: string;
|
|
856
|
+
} & SDK<"node">;
|
|
857
|
+
hysteria2: (input: Input<Omit<{
|
|
858
|
+
readonly id: string;
|
|
859
|
+
readonly server: string;
|
|
860
|
+
readonly port: number;
|
|
861
|
+
readonly via?: string;
|
|
862
|
+
readonly type: "hysteria2";
|
|
863
|
+
readonly tcpFastOpen?: never;
|
|
864
|
+
readonly password: SecretRef;
|
|
865
|
+
readonly serverName?: string;
|
|
866
|
+
readonly skipCertVerify?: boolean;
|
|
867
|
+
readonly portHopping?: string;
|
|
868
|
+
readonly portHoppingInterval?: number;
|
|
869
|
+
}, "label" | "via"> & {
|
|
870
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
871
|
+
readonly name?: string;
|
|
872
|
+
} & SDK<"node">>) => Omit<{
|
|
873
|
+
readonly id: string;
|
|
874
|
+
readonly server: string;
|
|
875
|
+
readonly port: number;
|
|
876
|
+
readonly via?: string;
|
|
877
|
+
readonly type: "hysteria2";
|
|
878
|
+
readonly tcpFastOpen?: never;
|
|
879
|
+
readonly password: SecretRef;
|
|
880
|
+
readonly serverName?: string;
|
|
881
|
+
readonly skipCertVerify?: boolean;
|
|
882
|
+
readonly portHopping?: string;
|
|
883
|
+
readonly portHoppingInterval?: number;
|
|
884
|
+
}, "label" | "via"> & {
|
|
885
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
886
|
+
readonly name?: string;
|
|
887
|
+
} & SDK<"node">;
|
|
888
|
+
shadowsocks: (input: Input<Omit<{
|
|
889
|
+
readonly id: string;
|
|
890
|
+
readonly server: string;
|
|
891
|
+
readonly port: number;
|
|
892
|
+
readonly via?: string;
|
|
893
|
+
readonly tcpFastOpen?: boolean;
|
|
894
|
+
readonly type: "shadowsocks";
|
|
895
|
+
readonly method: "aes-128-gcm" | "aes-256-gcm" | "chacha20-ietf-poly1305";
|
|
896
|
+
readonly password: SecretRef;
|
|
897
|
+
readonly surge?: {
|
|
898
|
+
readonly udpRelay?: boolean;
|
|
899
|
+
readonly blockQuic?: "auto" | "on" | "off";
|
|
900
|
+
} | undefined;
|
|
901
|
+
}, "label" | "via"> & {
|
|
902
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
903
|
+
readonly name?: string;
|
|
904
|
+
} & SDK<"node">>) => Omit<{
|
|
905
|
+
readonly id: string;
|
|
906
|
+
readonly server: string;
|
|
907
|
+
readonly port: number;
|
|
908
|
+
readonly via?: string;
|
|
909
|
+
readonly tcpFastOpen?: boolean;
|
|
910
|
+
readonly type: "shadowsocks";
|
|
911
|
+
readonly method: "aes-128-gcm" | "aes-256-gcm" | "chacha20-ietf-poly1305";
|
|
912
|
+
readonly password: SecretRef;
|
|
913
|
+
readonly surge?: {
|
|
914
|
+
readonly udpRelay?: boolean;
|
|
915
|
+
readonly blockQuic?: "auto" | "on" | "off";
|
|
916
|
+
} | undefined;
|
|
917
|
+
}, "label" | "via"> & {
|
|
918
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
919
|
+
readonly name?: string;
|
|
920
|
+
} & SDK<"node">;
|
|
921
|
+
vmess: (input: Input<Omit<{
|
|
922
|
+
readonly id: string;
|
|
923
|
+
readonly server: string;
|
|
924
|
+
readonly port: number;
|
|
925
|
+
readonly via?: string;
|
|
926
|
+
readonly tcpFastOpen?: boolean;
|
|
927
|
+
readonly type: "vmess";
|
|
928
|
+
readonly uuid: SecretRef;
|
|
929
|
+
readonly tls?: {
|
|
930
|
+
readonly serverName: string;
|
|
931
|
+
readonly alpn?: readonly string[] | undefined;
|
|
932
|
+
readonly skipCertVerify?: boolean;
|
|
933
|
+
} | undefined;
|
|
934
|
+
readonly transport?: {
|
|
935
|
+
readonly type: "ws";
|
|
936
|
+
readonly path: string;
|
|
937
|
+
readonly host?: string;
|
|
938
|
+
} | undefined;
|
|
939
|
+
readonly surge?: {
|
|
940
|
+
readonly blockQuic?: "auto" | "on" | "off";
|
|
941
|
+
} | undefined;
|
|
942
|
+
}, "label" | "via"> & {
|
|
943
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
944
|
+
readonly name?: string;
|
|
945
|
+
} & SDK<"node">>) => Omit<{
|
|
946
|
+
readonly id: string;
|
|
947
|
+
readonly server: string;
|
|
948
|
+
readonly port: number;
|
|
949
|
+
readonly via?: string;
|
|
950
|
+
readonly tcpFastOpen?: boolean;
|
|
951
|
+
readonly type: "vmess";
|
|
952
|
+
readonly uuid: SecretRef;
|
|
953
|
+
readonly tls?: {
|
|
954
|
+
readonly serverName: string;
|
|
955
|
+
readonly alpn?: readonly string[] | undefined;
|
|
956
|
+
readonly skipCertVerify?: boolean;
|
|
957
|
+
} | undefined;
|
|
958
|
+
readonly transport?: {
|
|
959
|
+
readonly type: "ws";
|
|
960
|
+
readonly path: string;
|
|
961
|
+
readonly host?: string;
|
|
962
|
+
} | undefined;
|
|
963
|
+
readonly surge?: {
|
|
964
|
+
readonly blockQuic?: "auto" | "on" | "off";
|
|
965
|
+
} | undefined;
|
|
966
|
+
}, "label" | "via"> & {
|
|
967
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
968
|
+
readonly name?: string;
|
|
969
|
+
} & SDK<"node">;
|
|
970
|
+
vless: (input: Input<Omit<{
|
|
971
|
+
readonly id: string;
|
|
972
|
+
readonly server: string;
|
|
973
|
+
readonly port: number;
|
|
974
|
+
readonly via?: string;
|
|
975
|
+
readonly tcpFastOpen?: boolean;
|
|
976
|
+
readonly type: "vless";
|
|
977
|
+
readonly uuid: SecretRef;
|
|
978
|
+
readonly tls?: {
|
|
979
|
+
readonly serverName: string;
|
|
980
|
+
readonly alpn?: readonly string[] | undefined;
|
|
981
|
+
readonly skipCertVerify?: boolean;
|
|
982
|
+
} | undefined;
|
|
983
|
+
readonly transport?: {
|
|
984
|
+
readonly type: "ws";
|
|
985
|
+
readonly path: string;
|
|
986
|
+
readonly host?: string;
|
|
987
|
+
} | undefined;
|
|
988
|
+
readonly flow?: "xtls-rprx-vision";
|
|
989
|
+
readonly packetEncoding?: "xudp" | "packetaddr";
|
|
990
|
+
readonly reality?: {
|
|
991
|
+
readonly publicKey: string;
|
|
992
|
+
readonly shortId: string;
|
|
993
|
+
} | undefined;
|
|
994
|
+
readonly utlsFingerprint?: "chrome";
|
|
995
|
+
}, "label" | "via"> & {
|
|
996
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
997
|
+
readonly name?: string;
|
|
998
|
+
} & SDK<"node">>) => Omit<{
|
|
999
|
+
readonly id: string;
|
|
1000
|
+
readonly server: string;
|
|
1001
|
+
readonly port: number;
|
|
1002
|
+
readonly via?: string;
|
|
1003
|
+
readonly tcpFastOpen?: boolean;
|
|
1004
|
+
readonly type: "vless";
|
|
1005
|
+
readonly uuid: SecretRef;
|
|
1006
|
+
readonly tls?: {
|
|
1007
|
+
readonly serverName: string;
|
|
1008
|
+
readonly alpn?: readonly string[] | undefined;
|
|
1009
|
+
readonly skipCertVerify?: boolean;
|
|
1010
|
+
} | undefined;
|
|
1011
|
+
readonly transport?: {
|
|
1012
|
+
readonly type: "ws";
|
|
1013
|
+
readonly path: string;
|
|
1014
|
+
readonly host?: string;
|
|
1015
|
+
} | undefined;
|
|
1016
|
+
readonly flow?: "xtls-rprx-vision";
|
|
1017
|
+
readonly packetEncoding?: "xudp" | "packetaddr";
|
|
1018
|
+
readonly reality?: {
|
|
1019
|
+
readonly publicKey: string;
|
|
1020
|
+
readonly shortId: string;
|
|
1021
|
+
} | undefined;
|
|
1022
|
+
readonly utlsFingerprint?: "chrome";
|
|
1023
|
+
}, "label" | "via"> & {
|
|
1024
|
+
readonly via?: ProxyNode | ProxyGroup;
|
|
1025
|
+
readonly name?: string;
|
|
1026
|
+
} & SDK<"node">;
|
|
885
1027
|
};
|
|
886
1028
|
export declare const surge: {
|
|
887
|
-
config: typeof surgeConfig;
|
|
888
1029
|
match: {
|
|
889
|
-
domain: (value: string, options?: {
|
|
890
|
-
readonly noResolve?: boolean;
|
|
891
|
-
readonly includeSniffed?: boolean;
|
|
892
|
-
} | undefined) => SurgeCondition;
|
|
893
|
-
domainSuffix: (value: string, options?: {
|
|
894
|
-
readonly noResolve?: boolean;
|
|
895
|
-
readonly includeSniffed?: boolean;
|
|
896
|
-
} | undefined) => SurgeCondition;
|
|
897
|
-
ipCidr: (value: string, options?: {
|
|
898
|
-
readonly noResolve?: boolean;
|
|
899
|
-
readonly includeSniffed?: never;
|
|
900
|
-
} | undefined) => SurgeCondition;
|
|
901
|
-
ipCidr6: (value: string, options?: {
|
|
902
|
-
readonly noResolve?: boolean;
|
|
903
|
-
readonly includeSniffed?: never;
|
|
904
|
-
} | undefined) => SurgeCondition;
|
|
905
1030
|
ipAsn: (value: number, options?: {
|
|
906
1031
|
readonly noResolve?: boolean;
|
|
907
1032
|
readonly includeSniffed?: never;
|
|
908
|
-
}) =>
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
readonly includeSniffed?: never;
|
|
916
|
-
} | undefined) => SurgeCondition;
|
|
917
|
-
macAddress: (value: string, options?: {
|
|
918
|
-
readonly noResolve?: boolean;
|
|
919
|
-
readonly includeSniffed?: never;
|
|
920
|
-
} | undefined) => SurgeCondition;
|
|
921
|
-
network: (value: "tcp" | "udp", options?: {
|
|
922
|
-
readonly noResolve?: boolean;
|
|
923
|
-
readonly includeSniffed?: never;
|
|
924
|
-
}) => SurgeCondition;
|
|
925
|
-
port: (from: number, to?: number, options?: {
|
|
926
|
-
readonly noResolve?: boolean;
|
|
927
|
-
readonly includeSniffed?: never;
|
|
928
|
-
}) => SurgeCondition;
|
|
929
|
-
sourcePort: (from: number, to?: number, options?: {
|
|
930
|
-
readonly noResolve?: boolean;
|
|
931
|
-
readonly includeSniffed?: never;
|
|
932
|
-
}) => SurgeCondition;
|
|
933
|
-
all: (conditions: readonly SurgeCondition[], options?: {
|
|
934
|
-
readonly noResolve?: boolean;
|
|
935
|
-
readonly includeSniffed?: never;
|
|
936
|
-
}) => SurgeCondition;
|
|
937
|
-
any: (conditions: readonly SurgeCondition[], options?: {
|
|
938
|
-
readonly noResolve?: boolean;
|
|
939
|
-
readonly includeSniffed?: never;
|
|
940
|
-
}) => SurgeCondition;
|
|
941
|
-
not: (value: SurgeCondition, options?: {
|
|
1033
|
+
}) => {
|
|
1034
|
+
noResolve?: boolean;
|
|
1035
|
+
includeSniffed?: never;
|
|
1036
|
+
type: "ipAsn";
|
|
1037
|
+
value: number;
|
|
1038
|
+
};
|
|
1039
|
+
ipCidr6: (value: string, options?: {
|
|
942
1040
|
readonly noResolve?: boolean;
|
|
943
1041
|
readonly includeSniffed?: never;
|
|
944
|
-
}) =>
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
}>, "type">) => SurgeCondition;
|
|
948
|
-
};
|
|
949
|
-
smart: () => Extract<GroupAlgorithm, {
|
|
950
|
-
type: "surge-smart";
|
|
951
|
-
}>;
|
|
952
|
-
ruleSet: {
|
|
953
|
-
(input: Omit<NativeInput<"surge">, "format"> & {
|
|
954
|
-
readonly format?: "rule-set" | "domain-set";
|
|
955
|
-
} & {
|
|
956
|
-
readonly to: ProfileDestination;
|
|
957
|
-
}): RouteDefinition;
|
|
958
|
-
(input: SurgeSetInput): {
|
|
959
|
-
readonly type: "nativeRuleSet";
|
|
960
|
-
readonly id: string;
|
|
961
|
-
readonly url: string;
|
|
962
|
-
} & {
|
|
963
|
-
readonly engine: "surge";
|
|
964
|
-
readonly format: "rule-set" | "domain-set";
|
|
965
|
-
readonly intervalSeconds?: number;
|
|
1042
|
+
}) => {
|
|
1043
|
+
readonly type: "ipCidr6";
|
|
1044
|
+
readonly value: string;
|
|
966
1045
|
readonly noResolve?: boolean;
|
|
967
|
-
readonly includeSniffed?: boolean;
|
|
968
1046
|
};
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
(input: Omit<{
|
|
974
|
-
readonly type: "nativeRuleSet";
|
|
975
|
-
readonly id: string;
|
|
976
|
-
readonly url: string;
|
|
977
|
-
} & {
|
|
978
|
-
readonly engine: "mihomo";
|
|
979
|
-
readonly format: "yaml" | "text";
|
|
980
|
-
readonly behavior: "domain" | "ipcidr" | "classical";
|
|
981
|
-
readonly intervalSeconds: number;
|
|
982
|
-
}, "engine" | "id" | "type"> & {
|
|
983
|
-
readonly id?: string;
|
|
984
|
-
} & {
|
|
985
|
-
readonly to: ProfileDestination;
|
|
986
|
-
}): RouteDefinition;
|
|
987
|
-
(input: NativeInput<"mihomo">): {
|
|
988
|
-
readonly type: "nativeRuleSet";
|
|
989
|
-
readonly id: string;
|
|
990
|
-
readonly url: string;
|
|
991
|
-
} & {
|
|
992
|
-
readonly engine: "mihomo";
|
|
993
|
-
readonly format: "yaml" | "text";
|
|
994
|
-
readonly behavior: "domain" | "ipcidr" | "classical";
|
|
995
|
-
readonly intervalSeconds: number;
|
|
1047
|
+
macAddress: (value: string) => {
|
|
1048
|
+
readonly type: "macAddress";
|
|
1049
|
+
readonly value: string;
|
|
1050
|
+
readonly noResolve?: boolean;
|
|
996
1051
|
};
|
|
997
1052
|
};
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
} &
|
|
1011
|
-
readonly to: ProfileDestination;
|
|
1012
|
-
}): RouteDefinition;
|
|
1013
|
-
(input: NativeInput<"mihomo">): {
|
|
1014
|
-
readonly type: "nativeRuleSet";
|
|
1015
|
-
readonly id: string;
|
|
1016
|
-
readonly url: string;
|
|
1017
|
-
} & {
|
|
1018
|
-
readonly engine: "mihomo";
|
|
1019
|
-
readonly format: "yaml" | "text";
|
|
1020
|
-
readonly behavior: "domain" | "ipcidr" | "classical";
|
|
1021
|
-
readonly intervalSeconds: number;
|
|
1022
|
-
};
|
|
1053
|
+
ruleSets: {
|
|
1054
|
+
lan: {
|
|
1055
|
+
type: "ruleSet";
|
|
1056
|
+
id: "surge:lan";
|
|
1057
|
+
format: "rule-set";
|
|
1058
|
+
builtin: "LAN";
|
|
1059
|
+
} & SDK<"ruleSet">;
|
|
1060
|
+
system: {
|
|
1061
|
+
type: "ruleSet";
|
|
1062
|
+
id: "surge:system";
|
|
1063
|
+
format: "rule-set";
|
|
1064
|
+
builtin: "SYSTEM";
|
|
1065
|
+
} & SDK<"ruleSet">;
|
|
1023
1066
|
};
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1067
|
+
smart: () => {
|
|
1068
|
+
type: "surge-smart";
|
|
1069
|
+
} & SDK<"algorithm">;
|
|
1070
|
+
tailscale: (input: Input<{
|
|
1071
|
+
readonly type: "tailscale";
|
|
1072
|
+
readonly id: string;
|
|
1073
|
+
readonly sectionName: string;
|
|
1074
|
+
readonly authKey: SecretRef;
|
|
1075
|
+
readonly hostname: string;
|
|
1076
|
+
readonly dnsServer?: readonly string[] | undefined;
|
|
1077
|
+
readonly autoAddMagicDnsRule?: boolean | undefined;
|
|
1078
|
+
readonly idleKeepalive?: number | undefined;
|
|
1079
|
+
} & {
|
|
1080
|
+
readonly name?: string;
|
|
1081
|
+
} & SDK<"tunnel">>) => {
|
|
1082
|
+
readonly type: "tailscale";
|
|
1083
|
+
readonly id: string;
|
|
1084
|
+
readonly sectionName: string;
|
|
1085
|
+
readonly authKey: SecretRef;
|
|
1086
|
+
readonly hostname: string;
|
|
1087
|
+
readonly dnsServer?: readonly string[] | undefined;
|
|
1088
|
+
readonly autoAddMagicDnsRule?: boolean | undefined;
|
|
1089
|
+
readonly idleKeepalive?: number | undefined;
|
|
1090
|
+
} & {
|
|
1091
|
+
readonly name?: string;
|
|
1092
|
+
} & SDK<"tunnel">;
|
|
1093
|
+
wireguard: (input: Input<{
|
|
1094
|
+
readonly type: "wireguard";
|
|
1095
|
+
readonly id: string;
|
|
1096
|
+
readonly sectionName: string;
|
|
1097
|
+
readonly privateKey: SecretRef;
|
|
1098
|
+
readonly selfIp: string;
|
|
1099
|
+
readonly dnsServer?: readonly string[] | undefined;
|
|
1100
|
+
readonly mtu?: number | undefined;
|
|
1101
|
+
readonly peers: readonly {
|
|
1102
|
+
readonly publicKey: string;
|
|
1103
|
+
readonly endpoint: string;
|
|
1104
|
+
readonly allowedIps: readonly string[];
|
|
1105
|
+
readonly presharedKey?: SecretRef | undefined;
|
|
1106
|
+
readonly persistentKeepalive?: number | undefined;
|
|
1107
|
+
}[];
|
|
1108
|
+
} & {
|
|
1109
|
+
readonly name?: string;
|
|
1110
|
+
} & SDK<"tunnel">>) => {
|
|
1111
|
+
readonly type: "wireguard";
|
|
1112
|
+
readonly id: string;
|
|
1113
|
+
readonly sectionName: string;
|
|
1114
|
+
readonly privateKey: SecretRef;
|
|
1115
|
+
readonly selfIp: string;
|
|
1116
|
+
readonly dnsServer?: readonly string[] | undefined;
|
|
1117
|
+
readonly mtu?: number | undefined;
|
|
1118
|
+
readonly peers: readonly {
|
|
1119
|
+
readonly publicKey: string;
|
|
1120
|
+
readonly endpoint: string;
|
|
1121
|
+
readonly allowedIps: readonly string[];
|
|
1122
|
+
readonly presharedKey?: SecretRef | undefined;
|
|
1123
|
+
readonly persistentKeepalive?: number | undefined;
|
|
1124
|
+
}[];
|
|
1125
|
+
} & {
|
|
1126
|
+
readonly name?: string;
|
|
1127
|
+
} & SDK<"tunnel">;
|
|
1034
1128
|
};
|
|
1035
1129
|
export declare const singbox: {
|
|
1036
|
-
|
|
1037
|
-
(input: Omit<{
|
|
1038
|
-
readonly type: "nativeRuleSet";
|
|
1039
|
-
readonly id: string;
|
|
1040
|
-
readonly url: string;
|
|
1041
|
-
} & {
|
|
1042
|
-
readonly engine: "sing-box";
|
|
1043
|
-
readonly format: "source" | "binary";
|
|
1044
|
-
readonly intervalSeconds: number;
|
|
1045
|
-
}, "engine" | "id" | "type"> & {
|
|
1046
|
-
readonly id?: string;
|
|
1047
|
-
} & {
|
|
1048
|
-
readonly to: ProfileDestination;
|
|
1049
|
-
}): RouteDefinition;
|
|
1050
|
-
(input: NativeInput<"sing-box">): {
|
|
1051
|
-
readonly type: "nativeRuleSet";
|
|
1052
|
-
readonly id: string;
|
|
1053
|
-
readonly url: string;
|
|
1054
|
-
} & {
|
|
1055
|
-
readonly engine: "sing-box";
|
|
1056
|
-
readonly format: "source" | "binary";
|
|
1057
|
-
readonly intervalSeconds: number;
|
|
1058
|
-
};
|
|
1059
|
-
};
|
|
1060
|
-
tailscale: (options: Omit<TailscaleEndpoint, "type">) => TailscaleEndpoint;
|
|
1130
|
+
tailscale: (input: Input<SingBoxEndpoint>) => SingBoxEndpoint;
|
|
1061
1131
|
};
|
|
1062
1132
|
//#endregion
|
|
1063
|
-
//#region src/
|
|
1064
|
-
|
|
1065
|
-
readonly
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
readonly
|
|
1072
|
-
readonly filename: string;
|
|
1073
|
-
readonly content: string;
|
|
1133
|
+
//#region src/authoring/secret-inputs.d.ts
|
|
1134
|
+
type Source = ({
|
|
1135
|
+
readonly env: string;
|
|
1136
|
+
readonly value?: never;
|
|
1137
|
+
} | {
|
|
1138
|
+
readonly value: string;
|
|
1139
|
+
readonly env?: never;
|
|
1140
|
+
}) & {
|
|
1141
|
+
readonly validation?: string;
|
|
1074
1142
|
};
|
|
1075
|
-
|
|
1076
|
-
export declare function render(compilation: Compilation, resolveSecret: (token: Secret) => string | undefined): readonly Artifact[];
|
|
1143
|
+
export declare function defineSecrets<const T extends Record<string, Source>>(input: T): Secrets<Extract<keyof T, string>>;
|
|
1077
1144
|
//#endregion
|
|
1078
|
-
//#region src/
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
readonly secretReason?: "MISSING" | "RESOLUTION_FAILED";
|
|
1082
|
-
};
|
|
1145
|
+
//#region src/authoring/proxy-id.d.ts
|
|
1146
|
+
/** Stable identity independent of engine and mutable metadata. */
|
|
1147
|
+
export declare function proxyId(namespace: string, name: string): string;
|
|
1083
1148
|
//#endregion
|
|
1084
|
-
//#region src/
|
|
1085
|
-
type
|
|
1086
|
-
readonly
|
|
1087
|
-
readonly
|
|
1088
|
-
readonly
|
|
1089
|
-
|
|
1090
|
-
readonly active?: string;
|
|
1091
|
-
readonly generation?: string;
|
|
1092
|
-
readonly reason?: "ACCESS_DENIED" | "NO_SPACE" | "READ_ONLY" | "INVALID_DIRECTORY" | "IO_ERROR";
|
|
1093
|
-
readonly hint?: string;
|
|
1094
|
-
};
|
|
1095
|
-
/** All targets publish together by one active.json rename. Config files never go to stdout. */
|
|
1096
|
-
export declare function buildToDirectory(compilation: Compilation, output: string, resolveSecret?: (token: Secret) => string | undefined): Promise<BuildResult>;
|
|
1149
|
+
//#region src/model/build-types.d.ts
|
|
1150
|
+
type BuildDefinition = {
|
|
1151
|
+
readonly outDir?: string;
|
|
1152
|
+
readonly profiles: Readonly<Record<string, Profile>>;
|
|
1153
|
+
readonly secrets?: Secrets;
|
|
1154
|
+
} & SDK<"build">;
|
|
1097
1155
|
//#endregion
|
|
1098
|
-
//#region src/
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
readonly engine: Engine;
|
|
1102
|
-
readonly platform: "macos" | "linux";
|
|
1103
|
-
readonly version: string;
|
|
1104
|
-
};
|
|
1105
|
-
readonly nodes: readonly {
|
|
1106
|
-
readonly id: string;
|
|
1107
|
-
readonly nativeName: string;
|
|
1108
|
-
}[];
|
|
1109
|
-
readonly strategies: readonly Strategy[];
|
|
1110
|
-
readonly names?: Readonly<Record<string, string>>;
|
|
1111
|
-
};
|
|
1112
|
-
type StrategyGroupCompilation = {
|
|
1113
|
-
readonly ok: boolean;
|
|
1114
|
-
readonly artifactKind: "strategy-groups";
|
|
1115
|
-
readonly diagnostics: readonly Diagnostic[];
|
|
1116
|
-
readonly selections: readonly StrategySelection[];
|
|
1117
|
-
readonly content: string | null;
|
|
1118
|
-
};
|
|
1119
|
-
/** Only group topology/encoding is checked here; nodes, via, protocols and routes remain consumer-owned. */
|
|
1120
|
-
export declare function compileStrategyGroups(input: unknown): StrategyGroupCompilation;
|
|
1156
|
+
//#region src/authoring/build.d.ts
|
|
1157
|
+
/** Capture the immutable batch before any secret source is invoked. */
|
|
1158
|
+
export declare function defineBuild(input: Omit<BuildDefinition, keyof SDK<"build">>): BuildDefinition;
|
|
1121
1159
|
//#endregion
|
|
1122
|
-
//#region src/
|
|
1123
|
-
export declare class
|
|
1124
|
-
|
|
1160
|
+
//#region src/model/definitions.d.ts
|
|
1161
|
+
export declare class ProfileDefinitionError extends Error {
|
|
1162
|
+
readonly code: string;
|
|
1163
|
+
readonly paths?: readonly string[];
|
|
1164
|
+
readonly origin?: Origin;
|
|
1165
|
+
constructor(code: string, paths?: readonly string[]);
|
|
1125
1166
|
}
|
|
1126
1167
|
//#endregion
|
|
1127
|
-
//#region src/
|
|
1128
|
-
type
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1168
|
+
//#region src/authoring/index.d.ts
|
|
1169
|
+
export type HttpNode = Extract<ProxyNode, {
|
|
1170
|
+
type: "http";
|
|
1171
|
+
}>;
|
|
1172
|
+
export type TrojanNode = Extract<ProxyNode, {
|
|
1173
|
+
type: "trojan";
|
|
1174
|
+
}>;
|
|
1175
|
+
export type AnyTLSNode = Extract<ProxyNode, {
|
|
1176
|
+
type: "anytls";
|
|
1177
|
+
}>;
|
|
1178
|
+
export type Hysteria2Node = Extract<ProxyNode, {
|
|
1179
|
+
type: "hysteria2";
|
|
1180
|
+
}>;
|
|
1181
|
+
export type ShadowsocksNode = Extract<ProxyNode, {
|
|
1182
|
+
type: "shadowsocks";
|
|
1183
|
+
}>;
|
|
1184
|
+
export type VMessNode = Extract<ProxyNode, {
|
|
1185
|
+
type: "vmess";
|
|
1186
|
+
}>;
|
|
1187
|
+
export type VLESSNode = Extract<ProxyNode, {
|
|
1188
|
+
type: "vless";
|
|
1189
|
+
}>;
|
|
1190
|
+
//#endregion
|
|
1191
|
+
//#region src/model/inspect-profile.d.ts
|
|
1192
|
+
type Selection = {
|
|
1193
|
+
kind: "name";
|
|
1194
|
+
resource: string;
|
|
1195
|
+
nativeName: string;
|
|
1196
|
+
} | {
|
|
1197
|
+
kind: "algorithm";
|
|
1198
|
+
group: string;
|
|
1199
|
+
algorithm: "surge-smart" | "urltest";
|
|
1200
|
+
parameters?: object;
|
|
1201
|
+
} | {
|
|
1202
|
+
kind: "ruleSet";
|
|
1203
|
+
ruleSet: string;
|
|
1204
|
+
branch: "surge" | "singBox" | "mihomo";
|
|
1205
|
+
nativeName: string;
|
|
1164
1206
|
};
|
|
1165
|
-
export declare function compileProxyNodes(input: unknown): ProxyNodeCompilation;
|
|
1166
|
-
export declare function renderProxyNodes(compilation: ProxyNodeCompilation, resolveSecret: (token: Secret) => string | undefined): ProxyNodeArtifact;
|
|
1167
1207
|
//#endregion
|
|
1168
|
-
//#region src/
|
|
1169
|
-
|
|
1208
|
+
//#region src/build/explain.d.ts
|
|
1209
|
+
export declare function explainProfile(profile: Profile, request: RouteRequest, assume?: Assumptions): ExplainResult;
|
|
1210
|
+
//#endregion
|
|
1211
|
+
//#region src/build/index.d.ts
|
|
1212
|
+
type CheckResult = {
|
|
1170
1213
|
readonly ok: boolean;
|
|
1171
|
-
readonly code:
|
|
1172
|
-
readonly profileCount: number;
|
|
1214
|
+
readonly code: "CHECKED" | "CHECK_FAILED" | "CASE_FAILED";
|
|
1173
1215
|
readonly outputDirectoryChecked: boolean;
|
|
1174
1216
|
readonly profiles: readonly {
|
|
1175
|
-
readonly
|
|
1176
|
-
readonly
|
|
1217
|
+
readonly key: string;
|
|
1218
|
+
readonly target: Target;
|
|
1177
1219
|
readonly ok: boolean;
|
|
1178
|
-
readonly
|
|
1179
|
-
readonly
|
|
1180
|
-
readonly diagnostics: readonly Diagnostic[];
|
|
1220
|
+
readonly diagnostics: readonly ProfileDiagnostic[];
|
|
1221
|
+
readonly selections: readonly Selection[];
|
|
1181
1222
|
}[];
|
|
1223
|
+
readonly cases: readonly CaseResult[];
|
|
1182
1224
|
};
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
readonly
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
readonly
|
|
1189
|
-
readonly
|
|
1190
|
-
readonly
|
|
1191
|
-
readonly secrets?: (token: Secret, context: BuildContext) => string | undefined;
|
|
1192
|
-
};
|
|
1193
|
-
type ProfileBuildResult = BuildResult & {
|
|
1194
|
-
readonly warnings: Readonly<Record<string, number>>;
|
|
1195
|
-
readonly validation: boolean;
|
|
1196
|
-
readonly profileCount: number;
|
|
1225
|
+
type BuildResult = {
|
|
1226
|
+
readonly published: boolean;
|
|
1227
|
+
readonly exitCode: 0 | 1 | 2;
|
|
1228
|
+
readonly code: string;
|
|
1229
|
+
readonly check: CheckResult;
|
|
1230
|
+
readonly active?: string;
|
|
1231
|
+
readonly hint?: string;
|
|
1232
|
+
readonly secretName?: string;
|
|
1197
1233
|
};
|
|
1198
|
-
|
|
1199
|
-
export declare function
|
|
1200
|
-
/** Pure orchestration result; the CLI owns stdout and process exit status. */
|
|
1201
|
-
export declare function runBuild(input: BuildDefinition, output: string, options?: {
|
|
1234
|
+
export declare function checkBuild(definition: BuildDefinition): CheckResult;
|
|
1235
|
+
export declare function runBuild(definition: BuildDefinition, options?: {
|
|
1202
1236
|
readonly validation?: boolean;
|
|
1203
|
-
}): Promise<
|
|
1204
|
-
//#endregion
|
|
1205
|
-
//#region src/proxy-id.d.ts
|
|
1206
|
-
/** Stable identity independent of engine and mutable metadata. */
|
|
1207
|
-
export declare function proxyId(namespace: string, label: string): string;
|
|
1208
|
-
//#endregion
|
|
1209
|
-
//#region src/secret-inputs.d.ts
|
|
1210
|
-
type SecretsInput = {
|
|
1211
|
-
readonly values?: Readonly<Record<string, string>>;
|
|
1212
|
-
readonly env?: readonly string[];
|
|
1213
|
-
readonly validation?: Readonly<Record<string, string>>;
|
|
1214
|
-
};
|
|
1215
|
-
/** Capture declarations now; read only referenced, allowed environment names at render time. */
|
|
1216
|
-
export declare function secrets(input: SecretsInput, environment?: Readonly<Record<string, string | undefined>>): (token: Secret, context?: BuildContext) => string | undefined;
|
|
1237
|
+
}): Promise<BuildResult>;
|
|
1217
1238
|
//#endregion
|
|
1218
|
-
export type {
|
|
1239
|
+
export type { Assumptions, BuildDefinition, BuildResult, CaseResult, CheckResult, Condition, ProfileDiagnostic as Diagnostic, DnsRule, Exit, ExplainResult, Explanation, Fragments, GroupAlgorithm, Need, Origin, Profile, ProfileDefinition, ProxyBuilder, ProxyGroup, ProxyNode, Route, RouteCase, RouteRequest, RuleSet, SecretRef, Secrets, Selection, SingBoxEndpoint, SurgeGeneral, SurgeHost, SurgeTunnel, Target };
|