@nowcrew/daemon 0.5.29 → 0.5.31
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 +17 -1
- package/dist/config.js +13 -1
- package/dist/execution-journal.js +96 -5
- package/dist/execution-protocol.js +1 -0
- package/dist/execution-runner.js +52 -29
- package/dist/host-execution-coordinator.js +241 -0
- package/dist/local-executor.js +78 -0
- package/dist/machine-info.js +16 -1
- package/dist/remote/claude-bridge.js +402 -0
- package/dist/remote/claude-channel.js +164 -0
- package/dist/remote/codex-client.js +408 -0
- package/dist/remote/codex-runtime.js +77 -0
- package/dist/remote/config.js +83 -0
- package/dist/remote/gateway.js +572 -0
- package/dist/remote/protocol.js +178 -0
- package/dist/remote/remote-cli.js +233 -0
- package/dist/remote/session-discovery.js +249 -0
- package/dist/remote/wrapper.js +40 -0
- package/dist/runner.js +4 -0
- package/dist/runtime-startup-gate.js +91 -0
- package/dist/runtimes/codex-app-server-runner.js +226 -29
- package/dist/serve.js +70 -8
- package/dist/shared-execution-slots.js +48 -33
- package/package.json +1 -1
|
@@ -1,46 +1,58 @@
|
|
|
1
1
|
export function createSharedSlotManager(limits) {
|
|
2
2
|
const activeByHandle = new Map();
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const queue = [];
|
|
4
|
+
let activeTotal = 0;
|
|
5
|
+
const queuedFor = (handle) => queue.filter((entry) => !entry.released && entry.handle === handle).length;
|
|
6
|
+
const promote = () => {
|
|
7
|
+
while (activeTotal < limits.maxParallelTotal) {
|
|
8
|
+
const index = queue.findIndex((entry) => !entry.released
|
|
9
|
+
&& (activeByHandle.get(entry.handle) ?? 0) < limits.maxParallelPerAgent);
|
|
10
|
+
if (index < 0)
|
|
11
|
+
return;
|
|
12
|
+
const [next] = queue.splice(index, 1);
|
|
13
|
+
if (!next || next.released)
|
|
9
14
|
continue;
|
|
10
15
|
next.promoted = true;
|
|
11
|
-
|
|
16
|
+
activeTotal += 1;
|
|
17
|
+
activeByHandle.set(next.handle, (activeByHandle.get(next.handle) ?? 0) + 1);
|
|
12
18
|
next.resolve();
|
|
13
19
|
}
|
|
14
|
-
if (queue.length === 0)
|
|
15
|
-
queuesByHandle.delete(handle);
|
|
16
20
|
};
|
|
17
21
|
return {
|
|
18
22
|
reserve: (handle, kind) => {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const facts = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const activeForAgent = activeByHandle.get(handle) ?? 0;
|
|
24
|
+
const queuedForAgent = queuedFor(handle);
|
|
25
|
+
const facts = {
|
|
26
|
+
activeForAgent,
|
|
27
|
+
queuedForAgent,
|
|
28
|
+
activeTotal,
|
|
29
|
+
queuedTotal: queue.length,
|
|
30
|
+
};
|
|
31
|
+
const canStartImmediately = activeTotal < limits.maxParallelTotal
|
|
32
|
+
&& activeForAgent < limits.maxParallelPerAgent
|
|
33
|
+
&& queue.length === 0;
|
|
34
|
+
if (kind === "execution" && !canStartImmediately && (queuedForAgent >= limits.maxQueuedPerAgent
|
|
35
|
+
|| queue.length >= limits.maxQueuedTotal)) {
|
|
36
|
+
return {
|
|
37
|
+
accepted: false,
|
|
38
|
+
facts,
|
|
39
|
+
ready: Promise.resolve(),
|
|
40
|
+
isQueued: () => false,
|
|
41
|
+
release: () => { },
|
|
42
|
+
};
|
|
25
43
|
}
|
|
26
44
|
let resolveReady;
|
|
27
45
|
const ready = new Promise((resolve) => { resolveReady = resolve; });
|
|
28
46
|
const entry = {
|
|
29
|
-
|
|
47
|
+
handle,
|
|
30
48
|
released: false,
|
|
31
|
-
promoted:
|
|
49
|
+
promoted: false,
|
|
32
50
|
resolve: resolveReady,
|
|
33
51
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
resolveReady();
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
const queue = queuesByHandle.get(handle) ?? [];
|
|
40
|
-
queue.push(entry);
|
|
41
|
-
queuesByHandle.set(handle, queue);
|
|
42
|
-
}
|
|
52
|
+
queue.push(entry);
|
|
53
|
+
promote();
|
|
43
54
|
return {
|
|
55
|
+
accepted: true,
|
|
44
56
|
facts,
|
|
45
57
|
state: entry.promoted ? "ready" : "queued",
|
|
46
58
|
ready,
|
|
@@ -50,19 +62,22 @@ export function createSharedSlotManager(limits) {
|
|
|
50
62
|
return;
|
|
51
63
|
entry.released = true;
|
|
52
64
|
if (entry.promoted) {
|
|
53
|
-
|
|
65
|
+
activeTotal = Math.max(0, activeTotal - 1);
|
|
66
|
+
const nextForAgent = Math.max(0, (activeByHandle.get(handle) ?? 1) - 1);
|
|
67
|
+
if (nextForAgent === 0)
|
|
68
|
+
activeByHandle.delete(handle);
|
|
69
|
+
else
|
|
70
|
+
activeByHandle.set(handle, nextForAgent);
|
|
54
71
|
}
|
|
55
72
|
else {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
if (queue !== undefined && index >= 0)
|
|
73
|
+
const index = queue.indexOf(entry);
|
|
74
|
+
if (index >= 0)
|
|
59
75
|
queue.splice(index, 1);
|
|
60
|
-
if (queue?.length === 0)
|
|
61
|
-
queuesByHandle.delete(handle);
|
|
62
76
|
}
|
|
63
|
-
|
|
77
|
+
promote();
|
|
64
78
|
},
|
|
65
79
|
};
|
|
66
80
|
},
|
|
81
|
+
snapshot: () => ({ activeTotal, queuedTotal: queue.length }),
|
|
67
82
|
};
|
|
68
83
|
}
|