proxylang 0.1.3 → 0.1.5

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/dist/index.d.ts CHANGED
@@ -169,22 +169,37 @@ export type GroupAlgorithm = {
169
169
  readonly intervalSeconds?: number;
170
170
  readonly toleranceMs?: number;
171
171
  };
172
- export type Strategy = {
173
- readonly type: "strategy";
172
+ export type PortableAlgorithm = {
173
+ readonly type: "auto";
174
+ } | Extract<GroupAlgorithm, {
175
+ readonly type: "select" | "urltest";
176
+ }>;
177
+ export type StrategyImplementations = {
178
+ readonly surge?: GroupAlgorithm;
179
+ readonly "sing-box"?: GroupAlgorithm;
180
+ readonly mihomo?: GroupAlgorithm;
181
+ readonly stash?: GroupAlgorithm;
182
+ };
183
+ export type StrategyDefinition = {
174
184
  readonly id: string;
175
185
  readonly members: readonly string[];
176
- readonly implementations: {
177
- readonly surge?: GroupAlgorithm;
178
- readonly "sing-box"?: GroupAlgorithm;
179
- readonly mihomo?: GroupAlgorithm;
180
- readonly stash?: GroupAlgorithm;
181
- };
186
+ } & ({
187
+ readonly algorithm: PortableAlgorithm;
188
+ readonly implementations?: StrategyImplementations;
189
+ } | {
190
+ readonly algorithm?: never;
191
+ readonly implementations: StrategyImplementations;
192
+ });
193
+ export type Strategy = StrategyDefinition & {
194
+ readonly type: "strategy";
182
195
  };
183
196
  export type StrategySelection = {
184
197
  readonly id: string;
185
198
  readonly engine: Engine;
186
199
  readonly algorithm: GroupAlgorithm;
187
200
  readonly members: readonly string[];
201
+ readonly requestedAlgorithm?: PortableAlgorithm;
202
+ readonly implementationSource?: "default" | "override";
188
203
  };
189
204
  export type ConcreteGroup = {
190
205
  readonly id: string;
@@ -283,6 +298,202 @@ export type Explanation = {
283
298
  }[];
284
299
  };
285
300
  //#endregion
301
+ //#region src/surge-profile.d.ts
302
+ declare const policy$1: z.ZodUnion<readonly [z.ZodObject<{
303
+ ref: z.ZodString;
304
+ }, z.core.$strict>, z.ZodObject<{
305
+ builtin: z.ZodEnum<{
306
+ DIRECT: "DIRECT";
307
+ REJECT: "REJECT";
308
+ "REJECT-DROP": "REJECT-DROP";
309
+ "REJECT-NO-DROP": "REJECT-NO-DROP";
310
+ "REJECT-TINYGIF": "REJECT-TINYGIF";
311
+ }>;
312
+ }, z.core.$strict>]>;
313
+ type SurgePolicy = z.infer<typeof policy$1>;
314
+ declare const generalSchema: z.ZodObject<{
315
+ loglevel: z.ZodOptional<z.ZodEnum<{
316
+ info: "info";
317
+ notify: "notify";
318
+ verbose: "verbose";
319
+ warning: "warning";
320
+ }>>;
321
+ "dns-server": z.ZodOptional<z.ZodArray<z.ZodString>>;
322
+ "encrypted-dns-server": z.ZodOptional<z.ZodArray<z.ZodString>>;
323
+ "show-error-page-for-reject": z.ZodOptional<z.ZodBoolean>;
324
+ "exclude-simple-hostnames": z.ZodOptional<z.ZodBoolean>;
325
+ "internet-test-url": z.ZodOptional<z.ZodString>;
326
+ "skip-proxy": z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodString, z.ZodString]>>>;
327
+ ipv6: z.ZodOptional<z.ZodBoolean>;
328
+ "ipv6-vif": z.ZodOptional<z.ZodEnum<{
329
+ always: "always";
330
+ auto: "auto";
331
+ disabled: "disabled";
332
+ }>>;
333
+ "bypass-system": z.ZodOptional<z.ZodBoolean>;
334
+ replica: z.ZodOptional<z.ZodBoolean>;
335
+ "tls-provider": z.ZodOptional<z.ZodEnum<{
336
+ default: "default";
337
+ openssl: "openssl";
338
+ }>>;
339
+ "bypass-tun": z.ZodOptional<z.ZodArray<z.ZodString>>;
340
+ "always-real-ip": z.ZodOptional<z.ZodArray<z.ZodString>>;
341
+ "http-api": z.ZodOptional<z.ZodObject<{
342
+ password: z.ZodObject<{
343
+ type: z.ZodLiteral<"env">;
344
+ name: z.ZodString;
345
+ }, z.core.$strict>;
346
+ listen: z.ZodString;
347
+ }, z.core.$strict>>;
348
+ "http-api-web-dashboard": z.ZodOptional<z.ZodBoolean>;
349
+ "external-controller-access": z.ZodOptional<z.ZodObject<{
350
+ password: z.ZodObject<{
351
+ type: z.ZodLiteral<"env">;
352
+ name: z.ZodString;
353
+ }, z.core.$strict>;
354
+ listen: z.ZodString;
355
+ }, z.core.$strict>>;
356
+ "hijack-dns": z.ZodOptional<z.ZodArray<z.ZodString>>;
357
+ "http-listen": z.ZodOptional<z.ZodString>;
358
+ "socks5-listen": z.ZodOptional<z.ZodString>;
359
+ "proxy-restricted-to-lan": z.ZodOptional<z.ZodBoolean>;
360
+ }, z.core.$strict>;
361
+ type SurgeGeneral = z.infer<typeof generalSchema>;
362
+ declare const hostSchema: z.ZodObject<{
363
+ pattern: z.ZodString;
364
+ address: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
365
+ server: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
366
+ }, z.core.$strict>;
367
+ type SurgeHost = z.infer<typeof hostSchema>;
368
+ declare const tunnelSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
369
+ type: z.ZodLiteral<"tailscale">;
370
+ id: z.ZodString;
371
+ sectionName: z.ZodString;
372
+ authKey: z.ZodObject<{
373
+ type: z.ZodLiteral<"env">;
374
+ name: z.ZodString;
375
+ }, z.core.$strict>;
376
+ hostname: z.ZodString;
377
+ dnsServer: z.ZodOptional<z.ZodArray<z.ZodString>>;
378
+ autoAddMagicDnsRule: z.ZodOptional<z.ZodBoolean>;
379
+ idleKeepalive: z.ZodOptional<z.ZodNumber>;
380
+ }, z.core.$strict>, z.ZodObject<{
381
+ type: z.ZodLiteral<"wireguard">;
382
+ id: z.ZodString;
383
+ sectionName: z.ZodString;
384
+ privateKey: z.ZodObject<{
385
+ type: z.ZodLiteral<"env">;
386
+ name: z.ZodString;
387
+ }, z.core.$strict>;
388
+ selfIp: z.ZodString;
389
+ dnsServer: z.ZodOptional<z.ZodArray<z.ZodString>>;
390
+ mtu: z.ZodOptional<z.ZodNumber>;
391
+ peers: z.ZodArray<z.ZodObject<{
392
+ publicKey: z.ZodString;
393
+ endpoint: z.ZodString;
394
+ allowedIps: z.ZodArray<z.ZodString>;
395
+ presharedKey: z.ZodOptional<z.ZodObject<{
396
+ type: z.ZodLiteral<"env">;
397
+ name: z.ZodString;
398
+ }, z.core.$strict>>;
399
+ persistentKeepalive: z.ZodOptional<z.ZodNumber>;
400
+ }, z.core.$strict>>;
401
+ }, z.core.$strict>], "type">;
402
+ type SurgeTunnel = z.infer<typeof tunnelSchema>;
403
+ declare const groupSchema: z.ZodObject<{
404
+ id: z.ZodString;
405
+ type: z.ZodEnum<{
406
+ select: "select";
407
+ smart: "smart";
408
+ }>;
409
+ members: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
410
+ ref: z.ZodString;
411
+ }, z.core.$strict>, z.ZodObject<{
412
+ builtin: z.ZodEnum<{
413
+ DIRECT: "DIRECT";
414
+ REJECT: "REJECT";
415
+ "REJECT-DROP": "REJECT-DROP";
416
+ "REJECT-NO-DROP": "REJECT-NO-DROP";
417
+ "REJECT-TINYGIF": "REJECT-TINYGIF";
418
+ }>;
419
+ }, z.core.$strict>]>>;
420
+ url: z.ZodOptional<z.ZodString>;
421
+ intervalSeconds: z.ZodOptional<z.ZodNumber>;
422
+ timeoutSeconds: z.ZodOptional<z.ZodNumber>;
423
+ }, z.core.$strict>;
424
+ type SurgeGroup = z.infer<typeof groupSchema>;
425
+ type ConditionOptions = {
426
+ readonly noResolve?: boolean;
427
+ readonly extendedMatching?: boolean;
428
+ };
429
+ type SurgeCondition = ConditionOptions & ({
430
+ readonly type: "domain" | "domainSuffix" | "ipCidr" | "ipCidr6" | "sourceIp" | "processName" | "macAddress";
431
+ readonly value: string;
432
+ } | {
433
+ readonly type: "port" | "sourcePort";
434
+ readonly from: number;
435
+ readonly to?: number;
436
+ } | {
437
+ readonly type: "network";
438
+ readonly value: "tcp" | "udp";
439
+ } | {
440
+ readonly type: "all" | "any";
441
+ readonly conditions: readonly SurgeCondition[];
442
+ } | {
443
+ readonly type: "not";
444
+ readonly condition: SurgeCondition;
445
+ } | {
446
+ readonly type: "ruleSet";
447
+ readonly format: "rule-set" | "domain-set";
448
+ readonly url?: string;
449
+ readonly builtin?: "LAN" | "SYSTEM";
450
+ });
451
+ type SurgeRule = {
452
+ readonly when: SurgeCondition;
453
+ readonly then: SurgePolicy;
454
+ };
455
+ declare const managedSchema: z.ZodObject<{
456
+ url: z.ZodString;
457
+ query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
458
+ type: z.ZodLiteral<"env">;
459
+ name: z.ZodString;
460
+ }, z.core.$strict>]>>>;
461
+ intervalSeconds: z.ZodNumber;
462
+ strict: z.ZodBoolean;
463
+ }, z.core.$strict>;
464
+ type SurgeProfileInput = {
465
+ readonly target: {
466
+ readonly engine: "surge";
467
+ readonly platform: "macos" | "ios";
468
+ readonly version: string;
469
+ };
470
+ readonly managed?: z.infer<typeof managedSchema>;
471
+ readonly general?: SurgeGeneral;
472
+ readonly hosts?: readonly SurgeHost[];
473
+ readonly nodes: readonly ProxyNode[];
474
+ readonly tunnels?: readonly SurgeTunnel[];
475
+ readonly groups: readonly SurgeGroup[];
476
+ readonly rules: readonly SurgeRule[];
477
+ readonly fallback: SurgePolicy;
478
+ readonly names?: Readonly<Record<string, string>>;
479
+ };
480
+ type SurgeProfileCompilation = {
481
+ readonly ok: boolean;
482
+ readonly artifactKind: "surge-profile";
483
+ readonly diagnostics: readonly Diagnostic[];
484
+ readonly bindings: readonly {
485
+ readonly id: string;
486
+ readonly nativeName: string;
487
+ }[];
488
+ };
489
+ type SurgeProfileArtifact = {
490
+ readonly artifactKind: "surge-profile";
491
+ readonly content: string;
492
+ };
493
+ export declare function compileSurgeProfile(input: unknown): SurgeProfileCompilation;
494
+ export declare function renderSurgeProfile(compilation: SurgeProfileCompilation, resolveSecret: (token: Secret) => string | undefined): SurgeProfileArtifact;
495
+ export declare function renderSurgeProfiles(compilations: readonly SurgeProfileCompilation[], resolveSecret: (token: Secret) => string | undefined): readonly SurgeProfileArtifact[];
496
+ //#endregion
286
497
  //#region src/proxy-builder.d.ts
287
498
  type ProxyBuilder<N extends ProxyNode> = {
288
499
  readonly via: (id: string) => ProxyBuilder<N>;
@@ -341,16 +552,82 @@ export declare function selectNodes(nodes: readonly ProxyNode[], query?: {
341
552
  providers?: readonly string[];
342
553
  tags?: readonly string[];
343
554
  }): string[];
344
- /** A shared strategy explicitly chooses an algorithm for each engine. */
345
- export declare const strategy: (definition: Omit<Strategy, "type">) => Strategy;
555
+ /** A shared strategy declares an algorithm or explicitly selects native implementations. */
556
+ export declare const strategy: (definition: StrategyDefinition) => Strategy;
346
557
  export declare const group: {
347
- select: () => GroupAlgorithm;
558
+ auto: () => {
559
+ readonly type: "auto";
560
+ };
561
+ select: () => Extract<GroupAlgorithm, {
562
+ type: "select";
563
+ }>;
348
564
  urltest: (options: Omit<Extract<GroupAlgorithm, {
349
565
  type: "urltest";
350
- }>, "type">) => GroupAlgorithm;
566
+ }>, "type">) => Extract<GroupAlgorithm, {
567
+ type: "urltest";
568
+ }>;
351
569
  };
352
570
  export declare const surge: {
353
- smart: () => GroupAlgorithm;
571
+ match: {
572
+ domain: (value: string, options?: {
573
+ readonly noResolve?: boolean;
574
+ readonly extendedMatching?: boolean;
575
+ }) => SurgeCondition;
576
+ domainSuffix: (value: string, options?: {
577
+ readonly noResolve?: boolean;
578
+ readonly extendedMatching?: boolean;
579
+ }) => SurgeCondition;
580
+ ipCidr: (value: string, options?: {
581
+ readonly noResolve?: boolean;
582
+ readonly extendedMatching?: boolean;
583
+ }) => SurgeCondition;
584
+ ipCidr6: (value: string, options?: {
585
+ readonly noResolve?: boolean;
586
+ readonly extendedMatching?: boolean;
587
+ }) => SurgeCondition;
588
+ sourceIp: (value: string, options?: {
589
+ readonly noResolve?: boolean;
590
+ readonly extendedMatching?: boolean;
591
+ }) => SurgeCondition;
592
+ processName: (value: string, options?: {
593
+ readonly noResolve?: boolean;
594
+ readonly extendedMatching?: boolean;
595
+ }) => SurgeCondition;
596
+ macAddress: (value: string, options?: {
597
+ readonly noResolve?: boolean;
598
+ readonly extendedMatching?: boolean;
599
+ }) => SurgeCondition;
600
+ network: (value: "tcp" | "udp", options?: {
601
+ readonly noResolve?: boolean;
602
+ readonly extendedMatching?: boolean;
603
+ }) => SurgeCondition;
604
+ port: (from: number, to?: number, options?: {
605
+ readonly noResolve?: boolean;
606
+ readonly extendedMatching?: boolean;
607
+ }) => SurgeCondition;
608
+ sourcePort: (from: number, to?: number, options?: {
609
+ readonly noResolve?: boolean;
610
+ readonly extendedMatching?: boolean;
611
+ }) => SurgeCondition;
612
+ all: (conditions: readonly SurgeCondition[], options?: {
613
+ readonly noResolve?: boolean;
614
+ readonly extendedMatching?: boolean;
615
+ }) => SurgeCondition;
616
+ any: (conditions: readonly SurgeCondition[], options?: {
617
+ readonly noResolve?: boolean;
618
+ readonly extendedMatching?: boolean;
619
+ }) => SurgeCondition;
620
+ not: (value: SurgeCondition, options?: {
621
+ readonly noResolve?: boolean;
622
+ readonly extendedMatching?: boolean;
623
+ }) => SurgeCondition;
624
+ ruleSet: (options: Omit<Extract<SurgeCondition, {
625
+ type: "ruleSet";
626
+ }>, "type">) => SurgeCondition;
627
+ };
628
+ smart: () => Extract<GroupAlgorithm, {
629
+ type: "surge-smart";
630
+ }>;
354
631
  ruleSet: (options: Omit<Extract<NativeRuleSet, {
355
632
  engine: "surge";
356
633
  }>, "type" | "engine" | "format"> & {
@@ -382,6 +659,7 @@ export declare const singbox: {
382
659
  export declare const targetCatalog: readonly [{
383
660
  readonly engine: "sing-box";
384
661
  readonly version: "1.11.0";
662
+ readonly autoGroup: "urltest";
385
663
  readonly platforms: readonly ["linux", "macos"];
386
664
  readonly protocols: readonly ["trojan", "http", "shadowsocks", "vmess", "vless"];
387
665
  readonly endpoints: readonly [];
@@ -391,6 +669,7 @@ export declare const targetCatalog: readonly [{
391
669
  }, {
392
670
  readonly engine: "sing-box";
393
671
  readonly version: "1.12.0";
672
+ readonly autoGroup: "urltest";
394
673
  readonly platforms: readonly ["linux", "macos"];
395
674
  readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
396
675
  readonly endpoints: readonly ["sing-box-tailscale"];
@@ -400,6 +679,7 @@ export declare const targetCatalog: readonly [{
400
679
  }, {
401
680
  readonly engine: "surge";
402
681
  readonly version: "6.10.0";
682
+ readonly autoGroup: "surge-smart";
403
683
  readonly platforms: readonly ["macos"];
404
684
  readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess"];
405
685
  readonly endpoints: readonly [];
@@ -409,6 +689,7 @@ export declare const targetCatalog: readonly [{
409
689
  }, {
410
690
  readonly engine: "mihomo";
411
691
  readonly version: "1.19.32";
692
+ readonly autoGroup: "urltest";
412
693
  readonly platforms: readonly ["linux", "macos"];
413
694
  readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess", "vless"];
414
695
  readonly endpoints: readonly [];
@@ -418,6 +699,7 @@ export declare const targetCatalog: readonly [{
418
699
  }, {
419
700
  readonly engine: "stash";
420
701
  readonly version: "4.2.1";
702
+ readonly autoGroup: null;
421
703
  readonly platforms: readonly ["macos"];
422
704
  readonly protocols: readonly ["trojan", "http", "anytls", "shadowsocks", "vmess"];
423
705
  readonly endpoints: readonly [];
@@ -486,6 +768,8 @@ type BuildResult = {
486
768
  readonly code: string;
487
769
  readonly active?: string;
488
770
  readonly generation?: string;
771
+ readonly reason?: "ACCESS_DENIED" | "NO_SPACE" | "READ_ONLY" | "INVALID_DIRECTORY" | "IO_ERROR";
772
+ readonly hint?: string;
489
773
  };
490
774
  /** All targets publish together by one active.json rename. Config files never go to stdout. */
491
775
  export declare function buildToDirectory(compilation: Compilation, output: string, resolveSecret?: (token: Secret) => string | undefined): Promise<BuildResult>;
@@ -560,200 +844,73 @@ type ProxyNodeArtifact = {
560
844
  export declare function compileProxyNodes(input: unknown): ProxyNodeCompilation;
561
845
  export declare function renderProxyNodes(compilation: ProxyNodeCompilation, resolveSecret: (token: Secret) => string | undefined): ProxyNodeArtifact;
562
846
  //#endregion
563
- //#region src/surge-profile.d.ts
564
- declare const policy$1: z.ZodUnion<readonly [z.ZodObject<{
565
- ref: z.ZodString;
566
- }, z.core.$strict>, z.ZodObject<{
567
- builtin: z.ZodEnum<{
568
- DIRECT: "DIRECT";
569
- REJECT: "REJECT";
570
- "REJECT-DROP": "REJECT-DROP";
571
- "REJECT-NO-DROP": "REJECT-NO-DROP";
572
- "REJECT-TINYGIF": "REJECT-TINYGIF";
573
- }>;
574
- }, z.core.$strict>]>;
575
- type SurgePolicy = z.infer<typeof policy$1>;
576
- declare const generalSchema: z.ZodObject<{
577
- loglevel: z.ZodOptional<z.ZodEnum<{
578
- info: "info";
579
- notify: "notify";
580
- verbose: "verbose";
581
- warning: "warning";
582
- }>>;
583
- "dns-server": z.ZodOptional<z.ZodArray<z.ZodString>>;
584
- "encrypted-dns-server": z.ZodOptional<z.ZodArray<z.ZodString>>;
585
- "show-error-page-for-reject": z.ZodOptional<z.ZodBoolean>;
586
- "exclude-simple-hostnames": z.ZodOptional<z.ZodBoolean>;
587
- "internet-test-url": z.ZodOptional<z.ZodString>;
588
- "skip-proxy": z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodString, z.ZodString]>>>;
589
- ipv6: z.ZodOptional<z.ZodBoolean>;
590
- "ipv6-vif": z.ZodOptional<z.ZodEnum<{
591
- always: "always";
592
- auto: "auto";
593
- disabled: "disabled";
594
- }>>;
595
- "bypass-system": z.ZodOptional<z.ZodBoolean>;
596
- replica: z.ZodOptional<z.ZodBoolean>;
597
- "tls-provider": z.ZodOptional<z.ZodEnum<{
598
- default: "default";
599
- openssl: "openssl";
600
- }>>;
601
- "bypass-tun": z.ZodOptional<z.ZodArray<z.ZodString>>;
602
- "always-real-ip": z.ZodOptional<z.ZodArray<z.ZodString>>;
603
- "http-api": z.ZodOptional<z.ZodObject<{
604
- password: z.ZodObject<{
605
- type: z.ZodLiteral<"env">;
606
- name: z.ZodString;
607
- }, z.core.$strict>;
608
- listen: z.ZodString;
609
- }, z.core.$strict>>;
610
- "http-api-web-dashboard": z.ZodOptional<z.ZodBoolean>;
611
- "external-controller-access": z.ZodOptional<z.ZodObject<{
612
- password: z.ZodObject<{
613
- type: z.ZodLiteral<"env">;
614
- name: z.ZodString;
615
- }, z.core.$strict>;
616
- listen: z.ZodString;
617
- }, z.core.$strict>>;
618
- "hijack-dns": z.ZodOptional<z.ZodArray<z.ZodString>>;
619
- "http-listen": z.ZodOptional<z.ZodString>;
620
- "socks5-listen": z.ZodOptional<z.ZodString>;
621
- "proxy-restricted-to-lan": z.ZodOptional<z.ZodBoolean>;
622
- }, z.core.$strict>;
623
- type SurgeGeneral = z.infer<typeof generalSchema>;
624
- declare const hostSchema: z.ZodObject<{
625
- pattern: z.ZodString;
626
- address: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
627
- server: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
628
- }, z.core.$strict>;
629
- type SurgeHost = z.infer<typeof hostSchema>;
630
- declare const tunnelSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
631
- type: z.ZodLiteral<"tailscale">;
632
- id: z.ZodString;
633
- sectionName: z.ZodString;
634
- authKey: z.ZodObject<{
635
- type: z.ZodLiteral<"env">;
636
- name: z.ZodString;
637
- }, z.core.$strict>;
638
- hostname: z.ZodString;
639
- dnsServer: z.ZodOptional<z.ZodArray<z.ZodString>>;
640
- autoAddMagicDnsRule: z.ZodOptional<z.ZodBoolean>;
641
- idleKeepalive: z.ZodOptional<z.ZodNumber>;
642
- }, z.core.$strict>, z.ZodObject<{
643
- type: z.ZodLiteral<"wireguard">;
644
- id: z.ZodString;
645
- sectionName: z.ZodString;
646
- privateKey: z.ZodObject<{
647
- type: z.ZodLiteral<"env">;
648
- name: z.ZodString;
649
- }, z.core.$strict>;
650
- selfIp: z.ZodString;
651
- dnsServer: z.ZodOptional<z.ZodArray<z.ZodString>>;
652
- mtu: z.ZodOptional<z.ZodNumber>;
653
- peers: z.ZodArray<z.ZodObject<{
654
- publicKey: z.ZodString;
655
- endpoint: z.ZodString;
656
- allowedIps: z.ZodArray<z.ZodString>;
657
- presharedKey: z.ZodOptional<z.ZodObject<{
658
- type: z.ZodLiteral<"env">;
659
- name: z.ZodString;
660
- }, z.core.$strict>>;
661
- persistentKeepalive: z.ZodOptional<z.ZodNumber>;
662
- }, z.core.$strict>>;
663
- }, z.core.$strict>], "type">;
664
- type SurgeTunnel = z.infer<typeof tunnelSchema>;
665
- declare const groupSchema: z.ZodObject<{
666
- id: z.ZodString;
667
- type: z.ZodEnum<{
668
- select: "select";
669
- smart: "smart";
847
+ //#region src/surge-compose.d.ts
848
+ /** Bind shared names only for included resources; explicit input mappings remain compiler-checked. */
849
+ export declare function surgeProfile(input: SurgeProfileInput, names?: Readonly<Record<string, string>>): SurgeProfileInput;
850
+ /** Stable queries produce native-profile policy references without consumer mapping code. */
851
+ export declare function surgeMembers(nodes: readonly ProxyNode[], query?: Parameters<typeof selectNodes>[1]): SurgePolicy[];
852
+ //#endregion
853
+ //#region src/surge-host.d.ts
854
+ /** Complete-profile batches use the out symlink protocol; the Program host remains unchanged. */
855
+ export declare function buildSurgeProfilesToDirectory(profiles: Readonly<Record<string, SurgeProfileInput>>, output: string, resolveSecret?: (token: Secret) => string | undefined): Promise<BuildResult>;
856
+ //#endregion
857
+ //#region src/surge-definitions.d.ts
858
+ type Builtin = Extract<SurgePolicy, {
859
+ builtin: string;
860
+ }>;
861
+ type Destination = ProxyNode | ProxyGroupDefinition | SurgeTunnel | Builtin;
862
+ type ProxyGroupDefinition = {
863
+ readonly type: "proxy-group";
864
+ readonly id: string;
865
+ readonly name: string;
866
+ readonly algorithm: Extract<GroupAlgorithm, {
867
+ type: "select" | "surge-smart";
670
868
  }>;
671
- members: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
672
- ref: z.ZodString;
673
- }, z.core.$strict>, z.ZodObject<{
674
- builtin: z.ZodEnum<{
675
- DIRECT: "DIRECT";
676
- REJECT: "REJECT";
677
- "REJECT-DROP": "REJECT-DROP";
678
- "REJECT-NO-DROP": "REJECT-NO-DROP";
679
- "REJECT-TINYGIF": "REJECT-TINYGIF";
680
- }>;
681
- }, z.core.$strict>]>>;
682
- url: z.ZodOptional<z.ZodString>;
683
- intervalSeconds: z.ZodOptional<z.ZodNumber>;
684
- timeoutSeconds: z.ZodOptional<z.ZodNumber>;
685
- }, z.core.$strict>;
686
- type SurgeGroup = z.infer<typeof groupSchema>;
687
- type ConditionOptions = {
688
- readonly noResolve?: boolean;
689
- readonly extendedMatching?: boolean;
690
- };
691
- type SurgeCondition = ConditionOptions & ({
692
- readonly type: "domain" | "domainSuffix" | "ipCidr" | "ipCidr6" | "sourceIp" | "processName" | "macAddress";
693
- readonly value: string;
694
- } | {
695
- readonly type: "port" | "sourcePort";
696
- readonly from: number;
697
- readonly to?: number;
698
- } | {
699
- readonly type: "network";
700
- readonly value: "tcp" | "udp";
701
- } | {
702
- readonly type: "all" | "any";
703
- readonly conditions: readonly SurgeCondition[];
704
- } | {
705
- readonly type: "not";
706
- readonly condition: SurgeCondition;
707
- } | {
708
- readonly type: "ruleSet";
709
- readonly format: "rule-set" | "domain-set";
869
+ readonly members: readonly Destination[];
710
870
  readonly url?: string;
711
- readonly builtin?: "LAN" | "SYSTEM";
712
- });
713
- type SurgeRule = {
714
- readonly when: SurgeCondition;
715
- readonly then: SurgePolicy;
871
+ readonly intervalSeconds?: number;
872
+ readonly timeoutSeconds?: number;
716
873
  };
717
- declare const managedSchema: z.ZodObject<{
718
- url: z.ZodString;
719
- query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
720
- type: z.ZodLiteral<"env">;
721
- name: z.ZodString;
722
- }, z.core.$strict>]>>>;
723
- intervalSeconds: z.ZodNumber;
724
- strict: z.ZodBoolean;
725
- }, z.core.$strict>;
726
- type SurgeProfileInput = {
727
- readonly target: {
728
- readonly engine: "surge";
729
- readonly platform: "macos" | "ios";
730
- readonly version: string;
731
- };
732
- readonly managed?: z.infer<typeof managedSchema>;
733
- readonly general?: SurgeGeneral;
734
- readonly hosts?: readonly SurgeHost[];
735
- readonly nodes: readonly ProxyNode[];
736
- readonly tunnels?: readonly SurgeTunnel[];
737
- readonly groups: readonly SurgeGroup[];
738
- readonly rules: readonly SurgeRule[];
739
- readonly fallback: SurgePolicy;
740
- readonly names?: Readonly<Record<string, string>>;
874
+ type RouteDefinition = {
875
+ readonly type: "route";
876
+ readonly id: string;
877
+ readonly when: SurgeCondition;
878
+ readonly to: Destination;
741
879
  };
742
- type SurgeProfileCompilation = {
743
- readonly ok: boolean;
744
- readonly artifactKind: "surge-profile";
745
- readonly diagnostics: readonly Diagnostic[];
746
- readonly bindings: readonly {
747
- readonly id: string;
748
- readonly nativeName: string;
749
- }[];
880
+ type SurgeProfileDefinition = Omit<SurgeProfileInput, "groups" | "rules" | "fallback"> & {
881
+ readonly groups: readonly ProxyGroupDefinition[];
882
+ readonly routes: readonly RouteDefinition[];
883
+ readonly fallback: Destination;
750
884
  };
751
- type SurgeProfileArtifact = {
752
- readonly artifactKind: "surge-profile";
753
- readonly content: string;
885
+ export declare class ProfileDefinitionError extends Error {
886
+ readonly code: string;
887
+ constructor(code: string);
888
+ }
889
+ export declare const outbound: {
890
+ direct: Readonly<{
891
+ readonly builtin: "DIRECT";
892
+ }>;
893
+ reject: Readonly<{
894
+ readonly builtin: "REJECT";
895
+ }>;
896
+ rejectDrop: Readonly<{
897
+ readonly builtin: "REJECT-DROP";
898
+ }>;
899
+ rejectNoDrop: Readonly<{
900
+ readonly builtin: "REJECT-NO-DROP";
901
+ }>;
902
+ rejectTinyGif: Readonly<{
903
+ readonly builtin: "REJECT-TINYGIF";
904
+ }>;
754
905
  };
755
- export declare function compileSurgeProfile(input: unknown): SurgeProfileCompilation;
756
- export declare function renderSurgeProfile(compilation: SurgeProfileCompilation, resolveSecret: (token: Secret) => string | undefined): SurgeProfileArtifact;
757
- export declare function renderSurgeProfiles(compilations: readonly SurgeProfileCompilation[], resolveSecret: (token: Secret) => string | undefined): readonly SurgeProfileArtifact[];
906
+ export declare function defineProxyGroup(input: Omit<ProxyGroupDefinition, "type">): ProxyGroupDefinition;
907
+ export declare function defineRoute(input: Omit<RouteDefinition, "type">): RouteDefinition;
908
+ export declare function selectProxies(nodes: readonly ProxyNode[], query?: {
909
+ ids?: readonly string[];
910
+ regions?: readonly string[];
911
+ providers?: readonly string[];
912
+ tags?: readonly string[];
913
+ }): ProxyNode[];
914
+ export declare function defineSurgeProfile(input: SurgeProfileDefinition): SurgeProfileInput;
758
915
  //#endregion
759
- export type { Artifact, BuildResult, CaseResult, Compilation, ProxyBuilder, ProxyNodeArtifact, ProxyNodeCompilation, ProxyNodeInput, StrategyGroupCompilation, StrategyGroupInput, SurgeCondition, SurgeGeneral, SurgeGroup, SurgeHost, SurgePolicy, SurgeProfileArtifact, SurgeProfileCompilation, SurgeProfileInput, SurgeRule, SurgeTunnel, TargetPlan };
916
+ export type { Artifact, BuildResult, CaseResult, Compilation, Destination, ProxyBuilder, ProxyGroupDefinition, ProxyNodeArtifact, ProxyNodeCompilation, ProxyNodeInput, RouteDefinition, StrategyGroupCompilation, StrategyGroupInput, SurgeCondition, SurgeGeneral, SurgeGroup, SurgeHost, SurgePolicy, SurgeProfileArtifact, SurgeProfileCompilation, SurgeProfileDefinition, SurgeProfileInput, SurgeRule, SurgeTunnel, TargetPlan };