nx 22.5.0-beta.3 → 22.5.0-beta.4

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.
Files changed (43) hide show
  1. package/package.json +11 -11
  2. package/src/ai/constants.d.ts +1 -0
  3. package/src/ai/constants.d.ts.map +1 -1
  4. package/src/ai/constants.js +4 -0
  5. package/src/ai/set-up-ai-agents/set-up-ai-agents.d.ts.map +1 -1
  6. package/src/ai/set-up-ai-agents/set-up-ai-agents.js +22 -0
  7. package/src/command-line/configure-ai-agents/configure-ai-agents.d.ts.map +1 -1
  8. package/src/command-line/configure-ai-agents/configure-ai-agents.js +77 -43
  9. package/src/command-line/run/run-one.d.ts +1 -1
  10. package/src/command-line/run/run-one.d.ts.map +1 -1
  11. package/src/command-line/run/run-one.js +12 -9
  12. package/src/core/graph/main.js +1 -1
  13. package/src/daemon/server/server.d.ts.map +1 -1
  14. package/src/daemon/server/server.js +3 -2
  15. package/src/daemon/server/shutdown-utils.d.ts.map +1 -1
  16. package/src/daemon/server/shutdown-utils.js +1 -1
  17. package/src/executors/run-commands/running-tasks.d.ts.map +1 -1
  18. package/src/executors/run-commands/running-tasks.js +4 -4
  19. package/src/hasher/hash-task.d.ts +3 -3
  20. package/src/hasher/hash-task.d.ts.map +1 -1
  21. package/src/hasher/hash-task.js +24 -5
  22. package/src/hasher/native-task-hasher-impl.d.ts +1 -1
  23. package/src/hasher/native-task-hasher-impl.d.ts.map +1 -1
  24. package/src/hasher/native-task-hasher-impl.js +2 -2
  25. package/src/hasher/task-hasher.d.ts +4 -1
  26. package/src/hasher/task-hasher.d.ts.map +1 -1
  27. package/src/hasher/task-hasher.js +1 -0
  28. package/src/native/index.d.ts +18 -2
  29. package/src/native/nx.wasi.cjs +29 -28
  30. package/src/native/nx.wasm32-wasi.wasm +0 -0
  31. package/src/tasks-runner/cache.d.ts +2 -2
  32. package/src/tasks-runner/cache.d.ts.map +1 -1
  33. package/src/tasks-runner/cache.js +14 -11
  34. package/src/tasks-runner/forked-process-task-runner.d.ts +3 -3
  35. package/src/tasks-runner/forked-process-task-runner.d.ts.map +1 -1
  36. package/src/tasks-runner/forked-process-task-runner.js +12 -11
  37. package/src/tasks-runner/process-metrics-service.d.ts +2 -2
  38. package/src/tasks-runner/process-metrics-service.d.ts.map +1 -1
  39. package/src/tasks-runner/process-metrics-service.js +2 -2
  40. package/src/tasks-runner/run-command.d.ts.map +1 -1
  41. package/src/tasks-runner/task-io-service.d.ts +97 -0
  42. package/src/tasks-runner/task-io-service.d.ts.map +1 -0
  43. package/src/tasks-runner/task-io-service.js +146 -0
@@ -0,0 +1,97 @@
1
+ import { ProjectGraph } from '../config/project-graph';
2
+ import { TaskGraph } from '../config/task-graph';
3
+ /**
4
+ * Maps taskId -> PID. Note that this only Returns
5
+ * the PID that the main task process is running under,
6
+ * not any child processes it may have spawned. To fully
7
+ * trace the task's processes, you'll need to correlate
8
+ * spawned processes's PIDs with their parent PID.
9
+ */
10
+ export type TaskPidUpdate = {
11
+ taskId: string;
12
+ pid: number;
13
+ };
14
+ export type TaskPidCallback = (update: TaskPidUpdate) => void;
15
+ export type TaskInputInfo = {
16
+ taskId: string;
17
+ inputs: {
18
+ files: string[];
19
+ runtime: string[];
20
+ environment: string[];
21
+ depOutputs: string[];
22
+ external: string[];
23
+ };
24
+ };
25
+ export type TaskInputCallback = (taskInputInfo: TaskInputInfo) => void;
26
+ export type TaskOutputsUpdate = {
27
+ taskId: string;
28
+ outputs: string[];
29
+ };
30
+ export type TaskOutputsCallback = (update: TaskOutputsUpdate) => void;
31
+ /**
32
+ * Service for tracking task process IDs and providing access to task IO information.
33
+ * Subscribes to ProcessMetricsService for PID discovery.
34
+ * IO information comes from hash inputs (populated during hashing).
35
+ * Output files are reported when tasks are stored to cache.
36
+ */
37
+ declare class TaskIOService {
38
+ protected taskToPids: Map<string, number>;
39
+ protected taskToInputs: Map<string, TaskInputInfo>;
40
+ protected taskToOutputs: Map<string, string[]>;
41
+ private pidCallbacks;
42
+ private taskInputCallbacks;
43
+ private taskOutputsCallbacks;
44
+ protected projectGraph: ProjectGraph | null;
45
+ protected taskGraph: TaskGraph | null;
46
+ constructor(projectGraph?: ProjectGraph, taskGraph?: TaskGraph);
47
+ /**
48
+ * Subscribe to task PID updates.
49
+ * Receives notifications when processes are added/removed from tasks.
50
+ */
51
+ subscribeToTaskPids(callback: TaskPidCallback): void;
52
+ /**
53
+ * Subscribe to hash inputs as they are computed.
54
+ * Called when a task's hash inputs become available.
55
+ */
56
+ subscribeToTaskInputs(callback: TaskInputCallback): void;
57
+ /**
58
+ * Subscribe to task outputs as they are stored to cache.
59
+ * Called when a task's output files are collected for caching.
60
+ */
61
+ subscribeToTaskOutputs(callback: TaskOutputsCallback): void;
62
+ /**
63
+ * Notify subscribers that hash inputs are available for a task.
64
+ * Called from the hasher when inputs are computed.
65
+ */
66
+ notifyTaskInputs(taskId: string, inputs: {
67
+ files: string[];
68
+ runtime: string[];
69
+ environment: string[];
70
+ depOutputs: string[];
71
+ external: string[];
72
+ }): void;
73
+ /**
74
+ * Notify subscribers that task outputs have been collected.
75
+ * Called from the cache when outputs are stored.
76
+ */
77
+ notifyTaskOutputs(taskId: string, outputs: string[]): void;
78
+ /**
79
+ * Registers a PID to a task and notifies subscribers.
80
+ * @param update The TaskPidUpdate containing taskId and pid.
81
+ */
82
+ notifyPidUpdate(update: TaskPidUpdate): void;
83
+ }
84
+ /**
85
+ * Get or create the singleton TaskIOService instance.
86
+ * Optionally provide projectGraph and taskGraph to initialize with context.
87
+ */
88
+ export declare function getTaskIOService(projectGraph?: ProjectGraph, taskGraph?: TaskGraph): TaskIOService;
89
+ /**
90
+ * Register a task process start with both IO and metrics services.
91
+ * This is the standard way to notify the system that a task process has started.
92
+ * Both services need to be notified together - TaskIOService for external subscribers
93
+ * and ProcessMetricsService for native resource monitoring.
94
+ */
95
+ export declare function registerTaskProcessStart(taskId: string, pid: number): void;
96
+ export {};
97
+ //# sourceMappingURL=task-io-service.d.ts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,YAAY,CAAyB;IAC7C,OAAO,CAAC,kBAAkB,CAA2B;IACrD,OAAO,CAAC,oBAAoB,CAA6B;IAGzD,SAAS,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAAQ;IACnD,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAQ;gBAEjC,YAAY,CAAC,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,SAAS;IAS9D;;;OAGG;IACH,mBAAmB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAYpD;;;OAGG;IACH,qBAAqB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IASxD;;;OAGG;IACH,sBAAsB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;IAY3D;;;OAGG;IACH,gBAAgB,CACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,GACA,IAAI;IAgBP;;;OAGG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAiB1D;;;OAGG;IACH,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;CAU7C;AAKD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,CAAC,EAAE,YAAY,EAC3B,SAAS,CAAC,EAAE,SAAS,GACpB,aAAa,CAKf;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAG1E"}
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTaskIOService = getTaskIOService;
4
+ exports.registerTaskProcessStart = registerTaskProcessStart;
5
+ const process_metrics_service_1 = require("./process-metrics-service");
6
+ /**
7
+ * Service for tracking task process IDs and providing access to task IO information.
8
+ * Subscribes to ProcessMetricsService for PID discovery.
9
+ * IO information comes from hash inputs (populated during hashing).
10
+ * Output files are reported when tasks are stored to cache.
11
+ */
12
+ class TaskIOService {
13
+ constructor(projectGraph, taskGraph) {
14
+ // Used to call subscribers that were late to the party
15
+ this.taskToPids = new Map();
16
+ this.taskToInputs = new Map();
17
+ this.taskToOutputs = new Map();
18
+ // Subscription state
19
+ this.pidCallbacks = [];
20
+ this.taskInputCallbacks = [];
21
+ this.taskOutputsCallbacks = [];
22
+ // Project graph and task graph for resolving task information
23
+ this.projectGraph = null;
24
+ this.taskGraph = null;
25
+ if (projectGraph) {
26
+ this.projectGraph = projectGraph;
27
+ }
28
+ if (taskGraph) {
29
+ this.taskGraph = taskGraph;
30
+ }
31
+ }
32
+ /**
33
+ * Subscribe to task PID updates.
34
+ * Receives notifications when processes are added/removed from tasks.
35
+ */
36
+ subscribeToTaskPids(callback) {
37
+ this.pidCallbacks.push(callback);
38
+ // Emit current state to new subscriber
39
+ for (const [taskId, pid] of this.taskToPids) {
40
+ callback({
41
+ taskId,
42
+ pid,
43
+ });
44
+ }
45
+ }
46
+ /**
47
+ * Subscribe to hash inputs as they are computed.
48
+ * Called when a task's hash inputs become available.
49
+ */
50
+ subscribeToTaskInputs(callback) {
51
+ this.taskInputCallbacks.push(callback);
52
+ // Emit current state to new subscriber
53
+ for (const [, taskInputInfo] of this.taskToInputs) {
54
+ callback(taskInputInfo);
55
+ }
56
+ }
57
+ /**
58
+ * Subscribe to task outputs as they are stored to cache.
59
+ * Called when a task's output files are collected for caching.
60
+ */
61
+ subscribeToTaskOutputs(callback) {
62
+ this.taskOutputsCallbacks.push(callback);
63
+ // Emit current state to new subscriber
64
+ for (const [task, outputs] of this.taskToOutputs) {
65
+ callback({
66
+ taskId: task,
67
+ outputs: outputs,
68
+ });
69
+ }
70
+ }
71
+ /**
72
+ * Notify subscribers that hash inputs are available for a task.
73
+ * Called from the hasher when inputs are computed.
74
+ */
75
+ notifyTaskInputs(taskId, inputs) {
76
+ const taskInputInfo = {
77
+ taskId,
78
+ inputs,
79
+ };
80
+ this.taskToInputs.set(taskId, taskInputInfo);
81
+ for (const cb of this.taskInputCallbacks) {
82
+ try {
83
+ cb(taskInputInfo);
84
+ }
85
+ catch {
86
+ // Silent failure - don't let one callback break others
87
+ }
88
+ }
89
+ }
90
+ /**
91
+ * Notify subscribers that task outputs have been collected.
92
+ * Called from the cache when outputs are stored.
93
+ */
94
+ notifyTaskOutputs(taskId, outputs) {
95
+ this.taskToOutputs.set(taskId, outputs);
96
+ const update = {
97
+ taskId,
98
+ outputs,
99
+ };
100
+ for (const cb of this.taskOutputsCallbacks) {
101
+ try {
102
+ cb(update);
103
+ }
104
+ catch {
105
+ // Silent failure - don't let one callback break others
106
+ }
107
+ }
108
+ }
109
+ /**
110
+ * Registers a PID to a task and notifies subscribers.
111
+ * @param update The TaskPidUpdate containing taskId and pid.
112
+ */
113
+ notifyPidUpdate(update) {
114
+ this.taskToPids.set(update.taskId, update.pid);
115
+ for (const cb of this.pidCallbacks) {
116
+ try {
117
+ cb(update);
118
+ }
119
+ catch {
120
+ // Silent failure - don't let one callback break others
121
+ }
122
+ }
123
+ }
124
+ }
125
+ // Singleton
126
+ let instance = null;
127
+ /**
128
+ * Get or create the singleton TaskIOService instance.
129
+ * Optionally provide projectGraph and taskGraph to initialize with context.
130
+ */
131
+ function getTaskIOService(projectGraph, taskGraph) {
132
+ if (!instance) {
133
+ instance = new TaskIOService(projectGraph, taskGraph);
134
+ }
135
+ return instance;
136
+ }
137
+ /**
138
+ * Register a task process start with both IO and metrics services.
139
+ * This is the standard way to notify the system that a task process has started.
140
+ * Both services need to be notified together - TaskIOService for external subscribers
141
+ * and ProcessMetricsService for native resource monitoring.
142
+ */
143
+ function registerTaskProcessStart(taskId, pid) {
144
+ getTaskIOService().notifyPidUpdate({ taskId, pid });
145
+ (0, process_metrics_service_1.getProcessMetricsService)().registerTaskProcess(taskId, pid);
146
+ }