@openspecui/core 2.3.4 → 2.3.6
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.mts +95 -46
- package/dist/index.mjs +82 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -19,13 +19,13 @@ declare const ChangeFileSchema: z.ZodObject<{
|
|
|
19
19
|
/** Optional byte size for files */
|
|
20
20
|
size: z.ZodOptional<z.ZodNumber>;
|
|
21
21
|
}, "strip", z.ZodTypeAny, {
|
|
22
|
-
type: "file" | "directory";
|
|
23
22
|
path: string;
|
|
23
|
+
type: "file" | "directory";
|
|
24
24
|
content?: string | undefined;
|
|
25
25
|
size?: number | undefined;
|
|
26
26
|
}, {
|
|
27
|
-
type: "file" | "directory";
|
|
28
27
|
path: string;
|
|
28
|
+
type: "file" | "directory";
|
|
29
29
|
content?: string | undefined;
|
|
30
30
|
size?: number | undefined;
|
|
31
31
|
}>;
|
|
@@ -306,11 +306,11 @@ declare const DeltaSpecSchema: z.ZodObject<{
|
|
|
306
306
|
/** Raw markdown content of the delta spec */
|
|
307
307
|
content: z.ZodString;
|
|
308
308
|
}, "strip", z.ZodTypeAny, {
|
|
309
|
-
content: string;
|
|
310
309
|
specId: string;
|
|
311
|
-
}, {
|
|
312
310
|
content: string;
|
|
311
|
+
}, {
|
|
313
312
|
specId: string;
|
|
313
|
+
content: string;
|
|
314
314
|
}>;
|
|
315
315
|
type DeltaSpec = z.infer<typeof DeltaSpecSchema>;
|
|
316
316
|
/**
|
|
@@ -488,11 +488,11 @@ declare const ChangeSchema: z.ZodObject<{
|
|
|
488
488
|
/** Raw markdown content of the delta spec */
|
|
489
489
|
content: z.ZodString;
|
|
490
490
|
}, "strip", z.ZodTypeAny, {
|
|
491
|
-
content: string;
|
|
492
491
|
specId: string;
|
|
493
|
-
}, {
|
|
494
492
|
content: string;
|
|
493
|
+
}, {
|
|
495
494
|
specId: string;
|
|
495
|
+
content: string;
|
|
496
496
|
}>, "many">>;
|
|
497
497
|
/** Optional metadata */
|
|
498
498
|
metadata: z.ZodOptional<z.ZodObject<{
|
|
@@ -549,8 +549,8 @@ declare const ChangeSchema: z.ZodObject<{
|
|
|
549
549
|
} | undefined;
|
|
550
550
|
design?: string | undefined;
|
|
551
551
|
deltaSpecs?: {
|
|
552
|
-
content: string;
|
|
553
552
|
specId: string;
|
|
553
|
+
content: string;
|
|
554
554
|
}[] | undefined;
|
|
555
555
|
}, {
|
|
556
556
|
id: string;
|
|
@@ -596,8 +596,8 @@ declare const ChangeSchema: z.ZodObject<{
|
|
|
596
596
|
} | undefined;
|
|
597
597
|
design?: string | undefined;
|
|
598
598
|
deltaSpecs?: {
|
|
599
|
-
content: string;
|
|
600
599
|
specId: string;
|
|
600
|
+
content: string;
|
|
601
601
|
}[] | undefined;
|
|
602
602
|
}>;
|
|
603
603
|
type Change = z.infer<typeof ChangeSchema>;
|
|
@@ -803,8 +803,8 @@ declare class OpenSpecAdapter {
|
|
|
803
803
|
} | undefined;
|
|
804
804
|
design?: string | undefined;
|
|
805
805
|
deltaSpecs?: {
|
|
806
|
-
content: string;
|
|
807
806
|
specId: string;
|
|
807
|
+
content: string;
|
|
808
808
|
}[] | undefined;
|
|
809
809
|
}[];
|
|
810
810
|
archivedCount: number;
|
|
@@ -1036,13 +1036,23 @@ interface WatchEvent {
|
|
|
1036
1036
|
type PathCallback = (events: WatchEvent[]) => void;
|
|
1037
1037
|
/** watcher 重建原因 */
|
|
1038
1038
|
type ProjectWatcherReinitializeReason = 'drop-events' | 'watcher-error' | 'missing-project-dir' | 'project-dir-replaced' | 'manual';
|
|
1039
|
+
type ProjectResidencyEvictionReason = Extract<ProjectWatcherReinitializeReason, 'missing-project-dir' | 'project-dir-replaced'>;
|
|
1040
|
+
type ProjectResidencyStatus = {
|
|
1041
|
+
state: 'active';
|
|
1042
|
+
} | {
|
|
1043
|
+
state: 'evicted';
|
|
1044
|
+
reason: ProjectResidencyEvictionReason;
|
|
1045
|
+
detectedAt: number;
|
|
1046
|
+
};
|
|
1039
1047
|
/** watcher 运行时状态(用于调试和运维观测) */
|
|
1040
1048
|
interface ProjectWatcherRuntimeStatus {
|
|
1041
1049
|
generation: number;
|
|
1042
1050
|
reinitializeCount: number;
|
|
1043
1051
|
lastReinitializeReason: ProjectWatcherReinitializeReason | null;
|
|
1044
1052
|
reinitializeReasonCounts: Readonly<Record<ProjectWatcherReinitializeReason, number>>;
|
|
1053
|
+
projectResidency: ProjectResidencyStatus;
|
|
1045
1054
|
}
|
|
1055
|
+
type ProjectWatcherRuntimeStatusListener = (status: ProjectWatcherRuntimeStatus) => void;
|
|
1046
1056
|
/**
|
|
1047
1057
|
* 项目监听器
|
|
1048
1058
|
*
|
|
@@ -1074,6 +1084,8 @@ declare class ProjectWatcher {
|
|
|
1074
1084
|
private reinitializeCount;
|
|
1075
1085
|
private lastReinitializeReason;
|
|
1076
1086
|
private reinitializeReasonCounts;
|
|
1087
|
+
private projectResidency;
|
|
1088
|
+
private runtimeStatusListeners;
|
|
1077
1089
|
constructor(projectDir: string, options?: {
|
|
1078
1090
|
debounceMs?: number;
|
|
1079
1091
|
ignore?: string[];
|
|
@@ -1159,10 +1171,16 @@ declare class ProjectWatcher {
|
|
|
1159
1171
|
* 获取 watcher 运行时状态
|
|
1160
1172
|
*/
|
|
1161
1173
|
get runtimeStatus(): ProjectWatcherRuntimeStatus;
|
|
1174
|
+
subscribeRuntimeStatus(listener: ProjectWatcherRuntimeStatusListener, options?: {
|
|
1175
|
+
emitCurrent?: boolean;
|
|
1176
|
+
}): () => void;
|
|
1162
1177
|
/**
|
|
1163
1178
|
* 记录重建统计
|
|
1164
1179
|
*/
|
|
1165
1180
|
private markReinitialized;
|
|
1181
|
+
private markProjectResidencyActive;
|
|
1182
|
+
private markProjectResidencyEvicted;
|
|
1183
|
+
private emitRuntimeStatus;
|
|
1166
1184
|
/**
|
|
1167
1185
|
* 重新初始化 watcher
|
|
1168
1186
|
*/
|
|
@@ -1241,6 +1259,9 @@ declare function getWatchedProjectDir(): string | null;
|
|
|
1241
1259
|
* 获取 watcher 运行时状态
|
|
1242
1260
|
*/
|
|
1243
1261
|
declare function getWatcherRuntimeStatus(): WatcherRuntimeStatus | null;
|
|
1262
|
+
declare function subscribeWatcherRuntimeStatus(listener: (status: WatcherRuntimeStatus | null) => void, options?: {
|
|
1263
|
+
emitCurrent?: boolean;
|
|
1264
|
+
}): () => void;
|
|
1244
1265
|
//#endregion
|
|
1245
1266
|
//#region src/watcher.d.ts
|
|
1246
1267
|
/**
|
|
@@ -1933,14 +1954,14 @@ declare const ArtifactStatusSchema: z.ZodObject<{
|
|
|
1933
1954
|
missingDeps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1934
1955
|
relativePath: z.ZodOptional<z.ZodString>;
|
|
1935
1956
|
}, "strip", z.ZodTypeAny, {
|
|
1936
|
-
status: "done" | "ready" | "blocked";
|
|
1937
1957
|
id: string;
|
|
1958
|
+
status: "done" | "ready" | "blocked";
|
|
1938
1959
|
outputPath: string;
|
|
1939
1960
|
missingDeps?: string[] | undefined;
|
|
1940
1961
|
relativePath?: string | undefined;
|
|
1941
1962
|
}, {
|
|
1942
|
-
status: "done" | "ready" | "blocked";
|
|
1943
1963
|
id: string;
|
|
1964
|
+
status: "done" | "ready" | "blocked";
|
|
1944
1965
|
outputPath: string;
|
|
1945
1966
|
missingDeps?: string[] | undefined;
|
|
1946
1967
|
relativePath?: string | undefined;
|
|
@@ -1958,14 +1979,14 @@ declare const ChangeStatusSchema: z.ZodObject<{
|
|
|
1958
1979
|
missingDeps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1959
1980
|
relativePath: z.ZodOptional<z.ZodString>;
|
|
1960
1981
|
}, "strip", z.ZodTypeAny, {
|
|
1961
|
-
status: "done" | "ready" | "blocked";
|
|
1962
1982
|
id: string;
|
|
1983
|
+
status: "done" | "ready" | "blocked";
|
|
1963
1984
|
outputPath: string;
|
|
1964
1985
|
missingDeps?: string[] | undefined;
|
|
1965
1986
|
relativePath?: string | undefined;
|
|
1966
1987
|
}, {
|
|
1967
|
-
status: "done" | "ready" | "blocked";
|
|
1968
1988
|
id: string;
|
|
1989
|
+
status: "done" | "ready" | "blocked";
|
|
1969
1990
|
outputPath: string;
|
|
1970
1991
|
missingDeps?: string[] | undefined;
|
|
1971
1992
|
relativePath?: string | undefined;
|
|
@@ -1976,8 +1997,8 @@ declare const ChangeStatusSchema: z.ZodObject<{
|
|
|
1976
1997
|
isComplete: boolean;
|
|
1977
1998
|
applyRequires: string[];
|
|
1978
1999
|
artifacts: {
|
|
1979
|
-
status: "done" | "ready" | "blocked";
|
|
1980
2000
|
id: string;
|
|
2001
|
+
status: "done" | "ready" | "blocked";
|
|
1981
2002
|
outputPath: string;
|
|
1982
2003
|
missingDeps?: string[] | undefined;
|
|
1983
2004
|
relativePath?: string | undefined;
|
|
@@ -1988,8 +2009,8 @@ declare const ChangeStatusSchema: z.ZodObject<{
|
|
|
1988
2009
|
isComplete: boolean;
|
|
1989
2010
|
applyRequires: string[];
|
|
1990
2011
|
artifacts: {
|
|
1991
|
-
status: "done" | "ready" | "blocked";
|
|
1992
2012
|
id: string;
|
|
2013
|
+
status: "done" | "ready" | "blocked";
|
|
1993
2014
|
outputPath: string;
|
|
1994
2015
|
missingDeps?: string[] | undefined;
|
|
1995
2016
|
relativePath?: string | undefined;
|
|
@@ -2002,13 +2023,13 @@ declare const DependencyInfoSchema: z.ZodObject<{
|
|
|
2002
2023
|
path: z.ZodString;
|
|
2003
2024
|
description: z.ZodString;
|
|
2004
2025
|
}, "strip", z.ZodTypeAny, {
|
|
2005
|
-
path: string;
|
|
2006
2026
|
id: string;
|
|
2027
|
+
path: string;
|
|
2007
2028
|
description: string;
|
|
2008
2029
|
done: boolean;
|
|
2009
2030
|
}, {
|
|
2010
|
-
path: string;
|
|
2011
2031
|
id: string;
|
|
2032
|
+
path: string;
|
|
2012
2033
|
description: string;
|
|
2013
2034
|
done: boolean;
|
|
2014
2035
|
}>;
|
|
@@ -2116,13 +2137,13 @@ declare const ArtifactInstructionsSchema: z.ZodObject<{
|
|
|
2116
2137
|
path: z.ZodString;
|
|
2117
2138
|
description: z.ZodString;
|
|
2118
2139
|
}, "strip", z.ZodTypeAny, {
|
|
2119
|
-
path: string;
|
|
2120
2140
|
id: string;
|
|
2141
|
+
path: string;
|
|
2121
2142
|
description: string;
|
|
2122
2143
|
done: boolean;
|
|
2123
2144
|
}, {
|
|
2124
|
-
path: string;
|
|
2125
2145
|
id: string;
|
|
2146
|
+
path: string;
|
|
2126
2147
|
description: string;
|
|
2127
2148
|
done: boolean;
|
|
2128
2149
|
}>, "many">;
|
|
@@ -2136,8 +2157,8 @@ declare const ArtifactInstructionsSchema: z.ZodObject<{
|
|
|
2136
2157
|
artifactId: string;
|
|
2137
2158
|
template: string;
|
|
2138
2159
|
dependencies: {
|
|
2139
|
-
path: string;
|
|
2140
2160
|
id: string;
|
|
2161
|
+
path: string;
|
|
2141
2162
|
description: string;
|
|
2142
2163
|
done: boolean;
|
|
2143
2164
|
}[];
|
|
@@ -2154,8 +2175,8 @@ declare const ArtifactInstructionsSchema: z.ZodObject<{
|
|
|
2154
2175
|
artifactId: string;
|
|
2155
2176
|
template: string;
|
|
2156
2177
|
dependencies: {
|
|
2157
|
-
path: string;
|
|
2158
2178
|
id: string;
|
|
2179
|
+
path: string;
|
|
2159
2180
|
description: string;
|
|
2160
2181
|
done: boolean;
|
|
2161
2182
|
}[];
|
|
@@ -2201,8 +2222,8 @@ declare const SchemaResolutionSchema: z.ZodObject<{
|
|
|
2201
2222
|
displayPath?: string | undefined;
|
|
2202
2223
|
}>, "many">;
|
|
2203
2224
|
}, "strip", z.ZodTypeAny, {
|
|
2204
|
-
path: string;
|
|
2205
2225
|
name: string;
|
|
2226
|
+
path: string;
|
|
2206
2227
|
source: "project" | "user" | "package";
|
|
2207
2228
|
shadows: {
|
|
2208
2229
|
path: string;
|
|
@@ -2211,8 +2232,8 @@ declare const SchemaResolutionSchema: z.ZodObject<{
|
|
|
2211
2232
|
}[];
|
|
2212
2233
|
displayPath?: string | undefined;
|
|
2213
2234
|
}, {
|
|
2214
|
-
path: string;
|
|
2215
2235
|
name: string;
|
|
2236
|
+
path: string;
|
|
2216
2237
|
source: "project" | "user" | "package";
|
|
2217
2238
|
shadows: {
|
|
2218
2239
|
path: string;
|
|
@@ -2500,6 +2521,34 @@ interface GitWorktreeHandoff {
|
|
|
2500
2521
|
serverUrl: string;
|
|
2501
2522
|
}
|
|
2502
2523
|
//#endregion
|
|
2524
|
+
//#region src/runtime-types.d.ts
|
|
2525
|
+
type ProjectRecoveryStatus = {
|
|
2526
|
+
state: 'idle';
|
|
2527
|
+
} | {
|
|
2528
|
+
state: 'evicted';
|
|
2529
|
+
reason: ProjectResidencyEvictionReason;
|
|
2530
|
+
detectedAt: number;
|
|
2531
|
+
} | {
|
|
2532
|
+
state: 'resolving';
|
|
2533
|
+
reason: ProjectResidencyEvictionReason;
|
|
2534
|
+
detectedAt: number;
|
|
2535
|
+
} | {
|
|
2536
|
+
state: 'ready';
|
|
2537
|
+
reason: ProjectResidencyEvictionReason;
|
|
2538
|
+
detectedAt: number;
|
|
2539
|
+
handoff: GitWorktreeHandoff;
|
|
2540
|
+
} | {
|
|
2541
|
+
state: 'unavailable';
|
|
2542
|
+
reason: ProjectResidencyEvictionReason;
|
|
2543
|
+
detectedAt: number;
|
|
2544
|
+
message: string;
|
|
2545
|
+
} | {
|
|
2546
|
+
state: 'failed';
|
|
2547
|
+
reason: ProjectResidencyEvictionReason;
|
|
2548
|
+
detectedAt: number;
|
|
2549
|
+
message: string;
|
|
2550
|
+
};
|
|
2551
|
+
//#endregion
|
|
2503
2552
|
//#region src/opsx-kernel.d.ts
|
|
2504
2553
|
type TemplateContentMap = Record<string, {
|
|
2505
2554
|
content: string | null;
|
|
@@ -2613,22 +2662,22 @@ declare const PtySessionInfoSchema: z.ZodObject<{
|
|
|
2613
2662
|
closeTip: z.ZodOptional<z.ZodString>;
|
|
2614
2663
|
closeCallbackUrl: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
2615
2664
|
}, "strip", z.ZodTypeAny, {
|
|
2665
|
+
id: string;
|
|
2616
2666
|
command: string;
|
|
2617
2667
|
args: string[];
|
|
2618
2668
|
platform: "windows" | "macos" | "common";
|
|
2619
2669
|
exitCode: number | null;
|
|
2620
2670
|
title: string;
|
|
2621
|
-
id: string;
|
|
2622
2671
|
isExited: boolean;
|
|
2623
2672
|
closeTip?: string | undefined;
|
|
2624
2673
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
2625
2674
|
}, {
|
|
2675
|
+
id: string;
|
|
2626
2676
|
command: string;
|
|
2627
2677
|
args: string[];
|
|
2628
2678
|
platform: "windows" | "macos" | "common";
|
|
2629
2679
|
exitCode: number | null;
|
|
2630
2680
|
title: string;
|
|
2631
|
-
id: string;
|
|
2632
2681
|
isExited: boolean;
|
|
2633
2682
|
closeTip?: string | undefined;
|
|
2634
2683
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
@@ -2645,19 +2694,19 @@ declare const PtyCreateMessageSchema: z.ZodObject<{
|
|
|
2645
2694
|
}, "strip", z.ZodTypeAny, {
|
|
2646
2695
|
type: "create";
|
|
2647
2696
|
requestId: string;
|
|
2648
|
-
cols?: number | undefined;
|
|
2649
|
-
rows?: number | undefined;
|
|
2650
2697
|
command?: string | undefined;
|
|
2651
2698
|
args?: string[] | undefined;
|
|
2699
|
+
cols?: number | undefined;
|
|
2700
|
+
rows?: number | undefined;
|
|
2652
2701
|
closeTip?: string | undefined;
|
|
2653
2702
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
2654
2703
|
}, {
|
|
2655
2704
|
type: "create";
|
|
2656
2705
|
requestId: string;
|
|
2657
|
-
cols?: number | undefined;
|
|
2658
|
-
rows?: number | undefined;
|
|
2659
2706
|
command?: string | undefined;
|
|
2660
2707
|
args?: string[] | undefined;
|
|
2708
|
+
cols?: number | undefined;
|
|
2709
|
+
rows?: number | undefined;
|
|
2661
2710
|
closeTip?: string | undefined;
|
|
2662
2711
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
2663
2712
|
}>;
|
|
@@ -2735,19 +2784,19 @@ declare const PtyClientMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
2735
2784
|
}, "strip", z.ZodTypeAny, {
|
|
2736
2785
|
type: "create";
|
|
2737
2786
|
requestId: string;
|
|
2738
|
-
cols?: number | undefined;
|
|
2739
|
-
rows?: number | undefined;
|
|
2740
2787
|
command?: string | undefined;
|
|
2741
2788
|
args?: string[] | undefined;
|
|
2789
|
+
cols?: number | undefined;
|
|
2790
|
+
rows?: number | undefined;
|
|
2742
2791
|
closeTip?: string | undefined;
|
|
2743
2792
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
2744
2793
|
}, {
|
|
2745
2794
|
type: "create";
|
|
2746
2795
|
requestId: string;
|
|
2747
|
-
cols?: number | undefined;
|
|
2748
|
-
rows?: number | undefined;
|
|
2749
2796
|
command?: string | undefined;
|
|
2750
2797
|
args?: string[] | undefined;
|
|
2798
|
+
cols?: number | undefined;
|
|
2799
|
+
rows?: number | undefined;
|
|
2751
2800
|
closeTip?: string | undefined;
|
|
2752
2801
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
2753
2802
|
}>, z.ZodObject<{
|
|
@@ -2889,22 +2938,22 @@ declare const PtyListResponseSchema: z.ZodObject<{
|
|
|
2889
2938
|
closeTip: z.ZodOptional<z.ZodString>;
|
|
2890
2939
|
closeCallbackUrl: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
2891
2940
|
}, "strip", z.ZodTypeAny, {
|
|
2941
|
+
id: string;
|
|
2892
2942
|
command: string;
|
|
2893
2943
|
args: string[];
|
|
2894
2944
|
platform: "windows" | "macos" | "common";
|
|
2895
2945
|
exitCode: number | null;
|
|
2896
2946
|
title: string;
|
|
2897
|
-
id: string;
|
|
2898
2947
|
isExited: boolean;
|
|
2899
2948
|
closeTip?: string | undefined;
|
|
2900
2949
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
2901
2950
|
}, {
|
|
2951
|
+
id: string;
|
|
2902
2952
|
command: string;
|
|
2903
2953
|
args: string[];
|
|
2904
2954
|
platform: "windows" | "macos" | "common";
|
|
2905
2955
|
exitCode: number | null;
|
|
2906
2956
|
title: string;
|
|
2907
|
-
id: string;
|
|
2908
2957
|
isExited: boolean;
|
|
2909
2958
|
closeTip?: string | undefined;
|
|
2910
2959
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
@@ -2912,12 +2961,12 @@ declare const PtyListResponseSchema: z.ZodObject<{
|
|
|
2912
2961
|
}, "strip", z.ZodTypeAny, {
|
|
2913
2962
|
type: "list";
|
|
2914
2963
|
sessions: {
|
|
2964
|
+
id: string;
|
|
2915
2965
|
command: string;
|
|
2916
2966
|
args: string[];
|
|
2917
2967
|
platform: "windows" | "macos" | "common";
|
|
2918
2968
|
exitCode: number | null;
|
|
2919
2969
|
title: string;
|
|
2920
|
-
id: string;
|
|
2921
2970
|
isExited: boolean;
|
|
2922
2971
|
closeTip?: string | undefined;
|
|
2923
2972
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
@@ -2925,12 +2974,12 @@ declare const PtyListResponseSchema: z.ZodObject<{
|
|
|
2925
2974
|
}, {
|
|
2926
2975
|
type: "list";
|
|
2927
2976
|
sessions: {
|
|
2977
|
+
id: string;
|
|
2928
2978
|
command: string;
|
|
2929
2979
|
args: string[];
|
|
2930
2980
|
platform: "windows" | "macos" | "common";
|
|
2931
2981
|
exitCode: number | null;
|
|
2932
2982
|
title: string;
|
|
2933
|
-
id: string;
|
|
2934
2983
|
isExited: boolean;
|
|
2935
2984
|
closeTip?: string | undefined;
|
|
2936
2985
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
@@ -2943,14 +2992,14 @@ declare const PtyErrorResponseSchema: z.ZodObject<{
|
|
|
2943
2992
|
message: z.ZodString;
|
|
2944
2993
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
2945
2994
|
}, "strip", z.ZodTypeAny, {
|
|
2946
|
-
type: "error";
|
|
2947
2995
|
code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND" | "PTY_CREATE_FAILED";
|
|
2948
2996
|
message: string;
|
|
2997
|
+
type: "error";
|
|
2949
2998
|
sessionId?: string | undefined;
|
|
2950
2999
|
}, {
|
|
2951
|
-
type: "error";
|
|
2952
3000
|
code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND" | "PTY_CREATE_FAILED";
|
|
2953
3001
|
message: string;
|
|
3002
|
+
type: "error";
|
|
2954
3003
|
sessionId?: string | undefined;
|
|
2955
3004
|
}>;
|
|
2956
3005
|
declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
@@ -3029,22 +3078,22 @@ declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
3029
3078
|
closeTip: z.ZodOptional<z.ZodString>;
|
|
3030
3079
|
closeCallbackUrl: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
|
|
3031
3080
|
}, "strip", z.ZodTypeAny, {
|
|
3081
|
+
id: string;
|
|
3032
3082
|
command: string;
|
|
3033
3083
|
args: string[];
|
|
3034
3084
|
platform: "windows" | "macos" | "common";
|
|
3035
3085
|
exitCode: number | null;
|
|
3036
3086
|
title: string;
|
|
3037
|
-
id: string;
|
|
3038
3087
|
isExited: boolean;
|
|
3039
3088
|
closeTip?: string | undefined;
|
|
3040
3089
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
3041
3090
|
}, {
|
|
3091
|
+
id: string;
|
|
3042
3092
|
command: string;
|
|
3043
3093
|
args: string[];
|
|
3044
3094
|
platform: "windows" | "macos" | "common";
|
|
3045
3095
|
exitCode: number | null;
|
|
3046
3096
|
title: string;
|
|
3047
|
-
id: string;
|
|
3048
3097
|
isExited: boolean;
|
|
3049
3098
|
closeTip?: string | undefined;
|
|
3050
3099
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
@@ -3052,12 +3101,12 @@ declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
3052
3101
|
}, "strip", z.ZodTypeAny, {
|
|
3053
3102
|
type: "list";
|
|
3054
3103
|
sessions: {
|
|
3104
|
+
id: string;
|
|
3055
3105
|
command: string;
|
|
3056
3106
|
args: string[];
|
|
3057
3107
|
platform: "windows" | "macos" | "common";
|
|
3058
3108
|
exitCode: number | null;
|
|
3059
3109
|
title: string;
|
|
3060
|
-
id: string;
|
|
3061
3110
|
isExited: boolean;
|
|
3062
3111
|
closeTip?: string | undefined;
|
|
3063
3112
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
@@ -3065,12 +3114,12 @@ declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
3065
3114
|
}, {
|
|
3066
3115
|
type: "list";
|
|
3067
3116
|
sessions: {
|
|
3117
|
+
id: string;
|
|
3068
3118
|
command: string;
|
|
3069
3119
|
args: string[];
|
|
3070
3120
|
platform: "windows" | "macos" | "common";
|
|
3071
3121
|
exitCode: number | null;
|
|
3072
3122
|
title: string;
|
|
3073
|
-
id: string;
|
|
3074
3123
|
isExited: boolean;
|
|
3075
3124
|
closeTip?: string | undefined;
|
|
3076
3125
|
closeCallbackUrl?: string | Record<string, string> | undefined;
|
|
@@ -3081,14 +3130,14 @@ declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
3081
3130
|
message: z.ZodString;
|
|
3082
3131
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
3083
3132
|
}, "strip", z.ZodTypeAny, {
|
|
3084
|
-
type: "error";
|
|
3085
3133
|
code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND" | "PTY_CREATE_FAILED";
|
|
3086
3134
|
message: string;
|
|
3135
|
+
type: "error";
|
|
3087
3136
|
sessionId?: string | undefined;
|
|
3088
3137
|
}, {
|
|
3089
|
-
type: "error";
|
|
3090
3138
|
code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND" | "PTY_CREATE_FAILED";
|
|
3091
3139
|
message: string;
|
|
3140
|
+
type: "error";
|
|
3092
3141
|
sessionId?: string | undefined;
|
|
3093
3142
|
}>]>;
|
|
3094
3143
|
type PtyClientMessage = z.infer<typeof PtyClientMessageSchema>;
|
|
@@ -3096,4 +3145,4 @@ type PtyServerMessage = z.infer<typeof PtyServerMessageSchema>;
|
|
|
3096
3145
|
type PtySessionInfo = z.infer<typeof PtySessionInfoSchema>;
|
|
3097
3146
|
type PtyPlatform = z.infer<typeof PtyPlatformSchema>;
|
|
3098
3147
|
//#endregion
|
|
3099
|
-
export { type AIToolOption, AI_TOOLS, type ApplyInstructions, ApplyInstructionsSchema, type ApplyTask, ApplyTaskSchema, type ArchiveMeta, type ArtifactInstructions, ArtifactInstructionsSchema, type ArtifactStatus, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, type Change, type ChangeFile, ChangeFileSchema, type ChangeMeta, ChangeSchema, type ChangeStatus, ChangeStatusSchema, CliExecutor, type CliResult, type CliRunnerAttempt, type CliSniffResult, type CliStreamEvent, type CodeEditorTheme, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET, type DashboardCardAvailability, type DashboardConfig, DashboardConfigSchema, type DashboardGitCommitEntry, type DashboardGitDiffStats, type DashboardGitEntry, type DashboardGitSnapshot, type DashboardGitUncommittedEntry, type DashboardGitWorktree, type DashboardMetricKey, type DashboardOverview, type DashboardSummary, type DashboardTrendKind, type DashboardTrendMeta, type DashboardTrendPoint, type DashboardTriColorTrendPoint, type Delta, type DeltaOperation, DeltaOperationType, DeltaSchema, type DeltaSpec, DeltaSpecSchema, type DependencyInfo, DependencyInfoSchema, type ExportSnapshot, type FileChangeEvent, type FileChangeType, type GitConfig, GitConfigSchema, type GitEntriesPage, type GitEntryCursor, type GitEntryDetail, type GitEntryFileDiff, type GitEntryFilePatch, type GitEntryFileSource, type GitEntryFileSummary, type GitEntryFiles, type GitEntryPatch, type GitEntrySelector, type GitEntryShell, type GitFileChangeType, type GitPatchFile, type GitPatchState, type GitWorktreeHandoff, type GitWorktreeOverview, type GitWorktreeSummary, type HostedAppChannelKind, type HostedAppChannelManifest, type HostedAppCompatibilityEntry, type HostedAppVersionManifest, type HostedBackendHealthResponse, MarkdownParser, OFFICIAL_APP_BASE_URL, OpenSpecAdapter, type OpenSpecUIConfig, OpenSpecUIConfigSchema, type OpenSpecUIConfigUpdate, OpenSpecWatcher, OpsxKernel, type PathCallback, ProjectWatcher, type ProjectWatcherReinitializeReason, type ProjectWatcherRuntimeStatus, PtyAttachMessageSchema, PtyBufferResponseSchema, type PtyClientMessage, PtyClientMessageSchema, PtyCloseMessageSchema, PtyCreateMessageSchema, PtyCreatedResponseSchema, PtyErrorCodeSchema, PtyErrorResponseSchema, PtyExitResponseSchema, PtyInputMessageSchema, PtyListMessageSchema, PtyListResponseSchema, PtyOutputResponseSchema, type PtyPlatform, PtyPlatformSchema, PtyResizeMessageSchema, type PtyServerMessage, PtyServerMessageSchema, type PtySessionInfo, PtyTitleResponseSchema, ReactiveContext, ReactiveState, type ReactiveStateOptions, type Requirement, RequirementSchema, type ResolvedCliRunner, type SchemaArtifact, SchemaArtifactSchema, type SchemaDetail, SchemaDetailSchema, type SchemaInfo, SchemaInfoSchema, type SchemaResolution, SchemaResolutionSchema, type Spec, type SpecMeta, SpecSchema, TOOL_WORKFLOW_TO_SKILL_DIR, type Task, TaskSchema, type TemplateContentMap, type TemplatesMap, TemplatesSchema, type TerminalConfig, TerminalConfigSchema, type TerminalRendererEngine, TerminalRendererEngineSchema, type ToolConfig, type ToolInitDelivery, type ToolInitState, type ToolInitStatus, type ToolWorkflowId, VIRTUAL_PROJECT_DIRNAME, type ValidationIssue, type ValidationResult, Validator, type WatchEvent, type WatchEventType, type WatcherRuntimeStatus, acquireWatcher, buildCliRunnerCandidates, buildHostedLaunchUrl, buildHostedVersionManifestUrl, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getDetectedProjectTools, getProjectWatcher, getToolById, getToolInitStates, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isHostedAppVersionManifest, isHostedBackendHealthResponse, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, normalizeHostedAppBaseUrl, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, resolveHostedAppBaseUrl, resolveHostedChannelForVersion, sniffGlobalCli, toOpsxDisplayPath };
|
|
3148
|
+
export { type AIToolOption, AI_TOOLS, type ApplyInstructions, ApplyInstructionsSchema, type ApplyTask, ApplyTaskSchema, type ArchiveMeta, type ArtifactInstructions, ArtifactInstructionsSchema, type ArtifactStatus, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, type Change, type ChangeFile, ChangeFileSchema, type ChangeMeta, ChangeSchema, type ChangeStatus, ChangeStatusSchema, CliExecutor, type CliResult, type CliRunnerAttempt, type CliSniffResult, type CliStreamEvent, type CodeEditorTheme, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET, type DashboardCardAvailability, type DashboardConfig, DashboardConfigSchema, type DashboardGitCommitEntry, type DashboardGitDiffStats, type DashboardGitEntry, type DashboardGitSnapshot, type DashboardGitUncommittedEntry, type DashboardGitWorktree, type DashboardMetricKey, type DashboardOverview, type DashboardSummary, type DashboardTrendKind, type DashboardTrendMeta, type DashboardTrendPoint, type DashboardTriColorTrendPoint, type Delta, type DeltaOperation, DeltaOperationType, DeltaSchema, type DeltaSpec, DeltaSpecSchema, type DependencyInfo, DependencyInfoSchema, type ExportSnapshot, type FileChangeEvent, type FileChangeType, type GitConfig, GitConfigSchema, type GitEntriesPage, type GitEntryCursor, type GitEntryDetail, type GitEntryFileDiff, type GitEntryFilePatch, type GitEntryFileSource, type GitEntryFileSummary, type GitEntryFiles, type GitEntryPatch, type GitEntrySelector, type GitEntryShell, type GitFileChangeType, type GitPatchFile, type GitPatchState, type GitWorktreeHandoff, type GitWorktreeOverview, type GitWorktreeSummary, type HostedAppChannelKind, type HostedAppChannelManifest, type HostedAppCompatibilityEntry, type HostedAppVersionManifest, type HostedBackendHealthResponse, MarkdownParser, OFFICIAL_APP_BASE_URL, OpenSpecAdapter, type OpenSpecUIConfig, OpenSpecUIConfigSchema, type OpenSpecUIConfigUpdate, OpenSpecWatcher, OpsxKernel, type PathCallback, type ProjectRecoveryStatus, type ProjectResidencyEvictionReason, type ProjectResidencyStatus, ProjectWatcher, type ProjectWatcherReinitializeReason, type ProjectWatcherRuntimeStatus, type ProjectWatcherRuntimeStatusListener, PtyAttachMessageSchema, PtyBufferResponseSchema, type PtyClientMessage, PtyClientMessageSchema, PtyCloseMessageSchema, PtyCreateMessageSchema, PtyCreatedResponseSchema, PtyErrorCodeSchema, PtyErrorResponseSchema, PtyExitResponseSchema, PtyInputMessageSchema, PtyListMessageSchema, PtyListResponseSchema, PtyOutputResponseSchema, type PtyPlatform, PtyPlatformSchema, PtyResizeMessageSchema, type PtyServerMessage, PtyServerMessageSchema, type PtySessionInfo, PtyTitleResponseSchema, ReactiveContext, ReactiveState, type ReactiveStateOptions, type Requirement, RequirementSchema, type ResolvedCliRunner, type SchemaArtifact, SchemaArtifactSchema, type SchemaDetail, SchemaDetailSchema, type SchemaInfo, SchemaInfoSchema, type SchemaResolution, SchemaResolutionSchema, type Spec, type SpecMeta, SpecSchema, TOOL_WORKFLOW_TO_SKILL_DIR, type Task, TaskSchema, type TemplateContentMap, type TemplatesMap, TemplatesSchema, type TerminalConfig, TerminalConfigSchema, type TerminalRendererEngine, TerminalRendererEngineSchema, type ToolConfig, type ToolInitDelivery, type ToolInitState, type ToolInitStatus, type ToolWorkflowId, VIRTUAL_PROJECT_DIRNAME, type ValidationIssue, type ValidationResult, Validator, type WatchEvent, type WatchEventType, type WatcherRuntimeStatus, acquireWatcher, buildCliRunnerCandidates, buildHostedLaunchUrl, buildHostedVersionManifestUrl, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getDetectedProjectTools, getProjectWatcher, getToolById, getToolInitStates, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isHostedAppVersionManifest, isHostedBackendHealthResponse, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, normalizeHostedAppBaseUrl, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, resolveHostedAppBaseUrl, resolveHostedChannelForVersion, sniffGlobalCli, subscribeWatcherRuntimeStatus, toOpsxDisplayPath };
|
package/dist/index.mjs
CHANGED
|
@@ -542,6 +542,8 @@ var ProjectWatcher = class {
|
|
|
542
542
|
"project-dir-replaced": 0,
|
|
543
543
|
manual: 0
|
|
544
544
|
};
|
|
545
|
+
projectResidency = { state: "active" };
|
|
546
|
+
runtimeStatusListeners = /* @__PURE__ */ new Set();
|
|
545
547
|
constructor(projectDir, options = {}) {
|
|
546
548
|
this.projectDir = getRealPath$1(projectDir);
|
|
547
549
|
this.debounceMs = options.debounceMs ?? DEBOUNCE_MS$1;
|
|
@@ -571,7 +573,9 @@ var ProjectWatcher = class {
|
|
|
571
573
|
this.initialized = true;
|
|
572
574
|
this.generation += 1;
|
|
573
575
|
this.projectDirFingerprint = this.getProjectDirFingerprint();
|
|
576
|
+
this.projectResidency = { state: "active" };
|
|
574
577
|
this.startPathLivenessMonitor();
|
|
578
|
+
this.emitRuntimeStatus();
|
|
575
579
|
}
|
|
576
580
|
/**
|
|
577
581
|
* 处理 watcher 错误
|
|
@@ -644,18 +648,23 @@ var ProjectWatcher = class {
|
|
|
644
648
|
if (!this.initialized || this.reinitializePending) return;
|
|
645
649
|
const current = this.getProjectDirFingerprint();
|
|
646
650
|
if (current === null) {
|
|
651
|
+
this.markProjectResidencyEvicted("missing-project-dir");
|
|
647
652
|
console.warn("[ProjectWatcher] Project directory missing, scheduling reinitialize...");
|
|
648
653
|
this.scheduleReinitialize("missing-project-dir");
|
|
649
654
|
return;
|
|
650
655
|
}
|
|
651
656
|
if (this.projectDirFingerprint === null) {
|
|
652
657
|
this.projectDirFingerprint = current;
|
|
658
|
+
this.markProjectResidencyActive();
|
|
653
659
|
return;
|
|
654
660
|
}
|
|
655
661
|
if (current !== this.projectDirFingerprint) {
|
|
662
|
+
this.markProjectResidencyEvicted("project-dir-replaced");
|
|
656
663
|
console.warn("[ProjectWatcher] Project directory replaced, scheduling reinitialize...");
|
|
657
664
|
this.scheduleReinitialize("project-dir-replaced");
|
|
665
|
+
return;
|
|
658
666
|
}
|
|
667
|
+
this.markProjectResidencyActive();
|
|
659
668
|
}
|
|
660
669
|
/**
|
|
661
670
|
* 处理原始事件
|
|
@@ -755,7 +764,15 @@ var ProjectWatcher = class {
|
|
|
755
764
|
generation: this.generation,
|
|
756
765
|
reinitializeCount: this.reinitializeCount,
|
|
757
766
|
lastReinitializeReason: this.lastReinitializeReason,
|
|
758
|
-
reinitializeReasonCounts: { ...this.reinitializeReasonCounts }
|
|
767
|
+
reinitializeReasonCounts: { ...this.reinitializeReasonCounts },
|
|
768
|
+
projectResidency: { ...this.projectResidency }
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
subscribeRuntimeStatus(listener, options = {}) {
|
|
772
|
+
this.runtimeStatusListeners.add(listener);
|
|
773
|
+
if (options.emitCurrent !== false) listener(this.runtimeStatus);
|
|
774
|
+
return () => {
|
|
775
|
+
this.runtimeStatusListeners.delete(listener);
|
|
759
776
|
};
|
|
760
777
|
}
|
|
761
778
|
/**
|
|
@@ -765,6 +782,29 @@ var ProjectWatcher = class {
|
|
|
765
782
|
this.reinitializeCount += 1;
|
|
766
783
|
this.lastReinitializeReason = reason;
|
|
767
784
|
this.reinitializeReasonCounts[reason] += 1;
|
|
785
|
+
this.emitRuntimeStatus();
|
|
786
|
+
}
|
|
787
|
+
markProjectResidencyActive() {
|
|
788
|
+
if (this.projectResidency.state === "active") return;
|
|
789
|
+
this.projectResidency = { state: "active" };
|
|
790
|
+
this.emitRuntimeStatus();
|
|
791
|
+
}
|
|
792
|
+
markProjectResidencyEvicted(reason) {
|
|
793
|
+
if (this.projectResidency.state === "evicted" && this.projectResidency.reason === reason) return;
|
|
794
|
+
this.projectResidency = {
|
|
795
|
+
state: "evicted",
|
|
796
|
+
reason,
|
|
797
|
+
detectedAt: Date.now()
|
|
798
|
+
};
|
|
799
|
+
this.emitRuntimeStatus();
|
|
800
|
+
}
|
|
801
|
+
emitRuntimeStatus() {
|
|
802
|
+
const status = this.runtimeStatus;
|
|
803
|
+
for (const listener of this.runtimeStatusListeners) try {
|
|
804
|
+
listener(status);
|
|
805
|
+
} catch (error) {
|
|
806
|
+
console.error("[ProjectWatcher] Runtime status listener failed:", error);
|
|
807
|
+
}
|
|
768
808
|
}
|
|
769
809
|
/**
|
|
770
810
|
* 重新初始化 watcher
|
|
@@ -780,6 +820,7 @@ var ProjectWatcher = class {
|
|
|
780
820
|
this.initialized = false;
|
|
781
821
|
this.initPromise = null;
|
|
782
822
|
this.projectDirFingerprint = null;
|
|
823
|
+
this.emitRuntimeStatus();
|
|
783
824
|
if (!existsSync(this.projectDir)) {
|
|
784
825
|
console.warn("[ProjectWatcher] Project directory does not exist, waiting for it to be created...");
|
|
785
826
|
this.waitForProjectDir("missing-project-dir");
|
|
@@ -842,6 +883,8 @@ var ProjectWatcher = class {
|
|
|
842
883
|
this.initialized = false;
|
|
843
884
|
this.initPromise = null;
|
|
844
885
|
this.projectDirFingerprint = null;
|
|
886
|
+
this.projectResidency = { state: "active" };
|
|
887
|
+
this.emitRuntimeStatus();
|
|
845
888
|
}
|
|
846
889
|
};
|
|
847
890
|
/**
|
|
@@ -894,6 +937,25 @@ const DEBOUNCE_MS = 100;
|
|
|
894
937
|
const subscriptionCache = /* @__PURE__ */ new Map();
|
|
895
938
|
/** 防抖定时器 */
|
|
896
939
|
const debounceTimers = /* @__PURE__ */ new Map();
|
|
940
|
+
const watcherRuntimeStatusListeners = /* @__PURE__ */ new Set();
|
|
941
|
+
let releaseProjectWatcherRuntimeSubscription = null;
|
|
942
|
+
function emitWatcherRuntimeStatus() {
|
|
943
|
+
const status = getWatcherRuntimeStatus();
|
|
944
|
+
for (const listener of watcherRuntimeStatusListeners) listener(status);
|
|
945
|
+
}
|
|
946
|
+
function bindProjectWatcherRuntimeStatus() {
|
|
947
|
+
releaseProjectWatcherRuntimeSubscription?.();
|
|
948
|
+
releaseProjectWatcherRuntimeSubscription = null;
|
|
949
|
+
if (!globalProjectWatcher) {
|
|
950
|
+
emitWatcherRuntimeStatus();
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
const forward = () => {
|
|
954
|
+
emitWatcherRuntimeStatus();
|
|
955
|
+
};
|
|
956
|
+
releaseProjectWatcherRuntimeSubscription = globalProjectWatcher.subscribeRuntimeStatus(forward, { emitCurrent: false });
|
|
957
|
+
emitWatcherRuntimeStatus();
|
|
958
|
+
}
|
|
897
959
|
/**
|
|
898
960
|
* 初始化 watcher pool
|
|
899
961
|
*
|
|
@@ -905,9 +967,14 @@ const debounceTimers = /* @__PURE__ */ new Map();
|
|
|
905
967
|
async function initWatcherPool(projectDir) {
|
|
906
968
|
const normalizedDir = getRealPath(projectDir);
|
|
907
969
|
if (globalProjectWatcher && globalProjectDir === normalizedDir) return;
|
|
908
|
-
if (globalProjectWatcher)
|
|
970
|
+
if (globalProjectWatcher) {
|
|
971
|
+
releaseProjectWatcherRuntimeSubscription?.();
|
|
972
|
+
releaseProjectWatcherRuntimeSubscription = null;
|
|
973
|
+
await globalProjectWatcher.close();
|
|
974
|
+
}
|
|
909
975
|
globalProjectDir = normalizedDir;
|
|
910
976
|
globalProjectWatcher = getProjectWatcher(normalizedDir);
|
|
977
|
+
bindProjectWatcherRuntimeStatus();
|
|
911
978
|
await globalProjectWatcher.init();
|
|
912
979
|
}
|
|
913
980
|
/**
|
|
@@ -989,10 +1056,13 @@ async function closeAllWatchers() {
|
|
|
989
1056
|
subscriptionCache.clear();
|
|
990
1057
|
debounceTimers.clear();
|
|
991
1058
|
if (globalProjectWatcher) {
|
|
1059
|
+
releaseProjectWatcherRuntimeSubscription?.();
|
|
1060
|
+
releaseProjectWatcherRuntimeSubscription = null;
|
|
992
1061
|
await globalProjectWatcher.close();
|
|
993
1062
|
globalProjectWatcher = null;
|
|
994
1063
|
globalProjectDir = null;
|
|
995
1064
|
}
|
|
1065
|
+
emitWatcherRuntimeStatus();
|
|
996
1066
|
}
|
|
997
1067
|
/**
|
|
998
1068
|
* 检查 watcher pool 是否已初始化
|
|
@@ -1019,7 +1089,15 @@ function getWatcherRuntimeStatus() {
|
|
|
1019
1089
|
generation: runtime.generation,
|
|
1020
1090
|
reinitializeCount: runtime.reinitializeCount,
|
|
1021
1091
|
lastReinitializeReason: runtime.lastReinitializeReason,
|
|
1022
|
-
reinitializeReasonCounts: runtime.reinitializeReasonCounts
|
|
1092
|
+
reinitializeReasonCounts: runtime.reinitializeReasonCounts,
|
|
1093
|
+
projectResidency: runtime.projectResidency
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
function subscribeWatcherRuntimeStatus(listener, options = {}) {
|
|
1097
|
+
watcherRuntimeStatusListeners.add(listener);
|
|
1098
|
+
if (options.emitCurrent !== false) listener(getWatcherRuntimeStatus());
|
|
1099
|
+
return () => {
|
|
1100
|
+
watcherRuntimeStatusListeners.delete(listener);
|
|
1023
1101
|
};
|
|
1024
1102
|
}
|
|
1025
1103
|
|
|
@@ -4436,4 +4514,4 @@ const PtyServerMessageSchema = z.discriminatedUnion("type", [
|
|
|
4436
4514
|
]);
|
|
4437
4515
|
|
|
4438
4516
|
//#endregion
|
|
4439
|
-
export { AI_TOOLS, ApplyInstructionsSchema, ApplyTaskSchema, ArtifactInstructionsSchema, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, ChangeFileSchema, ChangeSchema, ChangeStatusSchema, CliExecutor, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET, DashboardConfigSchema, DeltaOperationType, DeltaSchema, DeltaSpecSchema, DependencyInfoSchema, GitConfigSchema, MarkdownParser, OFFICIAL_APP_BASE_URL, OpenSpecAdapter, OpenSpecUIConfigSchema, OpenSpecWatcher, OpsxKernel, ProjectWatcher, PtyAttachMessageSchema, PtyBufferResponseSchema, PtyClientMessageSchema, PtyCloseMessageSchema, PtyCreateMessageSchema, PtyCreatedResponseSchema, PtyErrorCodeSchema, PtyErrorResponseSchema, PtyExitResponseSchema, PtyInputMessageSchema, PtyListMessageSchema, PtyListResponseSchema, PtyOutputResponseSchema, PtyPlatformSchema, PtyResizeMessageSchema, PtyServerMessageSchema, PtyTitleResponseSchema, ReactiveContext, ReactiveState, RequirementSchema, SchemaArtifactSchema, SchemaDetailSchema, SchemaInfoSchema, SchemaResolutionSchema, SpecSchema, TOOL_WORKFLOW_TO_SKILL_DIR, TaskSchema, TemplatesSchema, TerminalConfigSchema, TerminalRendererEngineSchema, VIRTUAL_PROJECT_DIRNAME, Validator, acquireWatcher, buildCliRunnerCandidates, buildHostedLaunchUrl, buildHostedVersionManifestUrl, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getDetectedProjectTools, getProjectWatcher, getToolById, getToolInitStates, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isHostedAppVersionManifest, isHostedBackendHealthResponse, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, normalizeHostedAppBaseUrl, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, resolveHostedAppBaseUrl, resolveHostedChannelForVersion, sniffGlobalCli, toOpsxDisplayPath };
|
|
4517
|
+
export { AI_TOOLS, ApplyInstructionsSchema, ApplyTaskSchema, ArtifactInstructionsSchema, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, ChangeFileSchema, ChangeSchema, ChangeStatusSchema, CliExecutor, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET, DashboardConfigSchema, DeltaOperationType, DeltaSchema, DeltaSpecSchema, DependencyInfoSchema, GitConfigSchema, MarkdownParser, OFFICIAL_APP_BASE_URL, OpenSpecAdapter, OpenSpecUIConfigSchema, OpenSpecWatcher, OpsxKernel, ProjectWatcher, PtyAttachMessageSchema, PtyBufferResponseSchema, PtyClientMessageSchema, PtyCloseMessageSchema, PtyCreateMessageSchema, PtyCreatedResponseSchema, PtyErrorCodeSchema, PtyErrorResponseSchema, PtyExitResponseSchema, PtyInputMessageSchema, PtyListMessageSchema, PtyListResponseSchema, PtyOutputResponseSchema, PtyPlatformSchema, PtyResizeMessageSchema, PtyServerMessageSchema, PtyTitleResponseSchema, ReactiveContext, ReactiveState, RequirementSchema, SchemaArtifactSchema, SchemaDetailSchema, SchemaInfoSchema, SchemaResolutionSchema, SpecSchema, TOOL_WORKFLOW_TO_SKILL_DIR, TaskSchema, TemplatesSchema, TerminalConfigSchema, TerminalRendererEngineSchema, VIRTUAL_PROJECT_DIRNAME, Validator, acquireWatcher, buildCliRunnerCandidates, buildHostedLaunchUrl, buildHostedVersionManifestUrl, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getDetectedProjectTools, getProjectWatcher, getToolById, getToolInitStates, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isHostedAppVersionManifest, isHostedBackendHealthResponse, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, normalizeHostedAppBaseUrl, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, resolveHostedAppBaseUrl, resolveHostedChannelForVersion, sniffGlobalCli, subscribeWatcherRuntimeStatus, toOpsxDisplayPath };
|